(self, filename, expected_output, args=None,
no_build=False,
assert_returncode=0, assert_identical=False, assert_all=False,
check_for_error=True,
interleaved_output=True,
regex=False,
input=None,
**kwargs)
| 1465 | |
| 1466 | # Does a complete test - builds, runs, checks output, etc. |
| 1467 | def _build_and_run(self, filename, expected_output, args=None, |
| 1468 | no_build=False, |
| 1469 | assert_returncode=0, assert_identical=False, assert_all=False, |
| 1470 | check_for_error=True, |
| 1471 | interleaved_output=True, |
| 1472 | regex=False, |
| 1473 | input=None, |
| 1474 | **kwargs): |
| 1475 | logger.debug(f'_build_and_run: {filename}') |
| 1476 | |
| 1477 | if no_build: |
| 1478 | js_file = filename |
| 1479 | else: |
| 1480 | js_file = self.build(filename, **kwargs) |
| 1481 | self.assertExists(js_file) |
| 1482 | |
| 1483 | engines = self.js_engines.copy() |
| 1484 | if len(engines) > 1 and not self.use_all_engines: |
| 1485 | engines = engines[:1] |
| 1486 | # In standalone mode, also add wasm vms as we should be able to run there too. |
| 1487 | if self.get_setting('STANDALONE_WASM'): |
| 1488 | # TODO once standalone wasm support is more stable, apply use_all_engines |
| 1489 | # like with js engines, but for now as we bring it up, test in all of them |
| 1490 | if not self.wasm_engines: |
| 1491 | if 'EMTEST_SKIP_WASM_ENGINE' in os.environ: |
| 1492 | self.skipTest('no wasm engine was found to run the standalone part of this test') |
| 1493 | else: |
| 1494 | logger.warning('no wasm engine was found to run the standalone part of this test (Use EMTEST_SKIP_WASM_ENGINE to skip)') |
| 1495 | engines += self.wasm_engines |
| 1496 | if len(engines) == 0: |
| 1497 | self.fail('No JS engine present to run this test with. Check %s and the paths therein.' % config.EM_CONFIG) |
| 1498 | for engine in engines: |
| 1499 | js_output = self.run_js(js_file, engine, args, |
| 1500 | input=input, |
| 1501 | assert_returncode=assert_returncode, |
| 1502 | interleaved_output=interleaved_output) |
| 1503 | js_output = js_output.replace('\r\n', '\n') |
| 1504 | if expected_output: |
| 1505 | if type(expected_output) not in {list, tuple}: |
| 1506 | expected_output = [expected_output] |
| 1507 | try: |
| 1508 | if assert_identical: |
| 1509 | self.assertIdentical(expected_output, js_output) |
| 1510 | elif assert_all or len(expected_output) == 1: |
| 1511 | for o in expected_output: |
| 1512 | self.assertContained(o, js_output, regex=regex) |
| 1513 | else: |
| 1514 | self.assertContained(expected_output, js_output, regex=regex) |
| 1515 | if assert_returncode == 0 and check_for_error: |
| 1516 | self.assertNotContained('ERROR', js_output) |
| 1517 | except self.failureException: |
| 1518 | print('(test did not pass in JS engine: %s)' % engine) |
| 1519 | raise |
| 1520 | return js_output |
| 1521 | |
| 1522 | def get_freetype_library(self): |
| 1523 | self.cflags += [ |
no test coverage detected