(self)
| 8705 | self.do_runf('core/test_wrap_malloc.c', 'done\n', cflags=args) |
| 8706 | |
| 8707 | def test_environment(self): |
| 8708 | self.set_setting('ASSERTIONS') |
| 8709 | |
| 8710 | def test(assert_returncode=0): |
| 8711 | self.do_core_test('test_hello_world.c', assert_returncode=assert_returncode) |
| 8712 | if self.get_setting('WASM_ESM_INTEGRATION'): |
| 8713 | js = read_file(self.output_name('test_hello_world.support')) |
| 8714 | else: |
| 8715 | js = read_file(self.output_name('test_hello_world')) |
| 8716 | assert ('require(' in js) == ('node' in self.get_setting('ENVIRONMENT')), 'we should have require() calls only if node js specified' |
| 8717 | |
| 8718 | for engine in self.js_engines: |
| 8719 | print(f'engine: {engine}') |
| 8720 | # set us to test in just this engine |
| 8721 | self.require_engine(engine, force=True) |
| 8722 | # tell the compiler to build with just that engine |
| 8723 | if engine_is_node(engine) or engine_is_bun(engine): |
| 8724 | right = 'node' |
| 8725 | wrong = 'shell' |
| 8726 | else: |
| 8727 | right = 'shell' |
| 8728 | wrong = 'node' |
| 8729 | # test with the right env |
| 8730 | self.set_setting('ENVIRONMENT', right) |
| 8731 | print('right ENVIRONMENT =', self.get_setting('ENVIRONMENT')) |
| 8732 | test() |
| 8733 | # test with the wrong env |
| 8734 | self.set_setting('ENVIRONMENT', wrong) |
| 8735 | print('wrong ENVIRONMENT =', self.get_setting('ENVIRONMENT')) |
| 8736 | try: |
| 8737 | test(assert_returncode=NON_ZERO) |
| 8738 | raise Exception('unexpected success') |
| 8739 | except Exception as e: |
| 8740 | self.assertContained(['environment detected but not enabled at build time', 'not compiled for this environment'], str(e)) |
| 8741 | # test with a combined env |
| 8742 | self.set_setting('ENVIRONMENT', right + ',' + wrong) |
| 8743 | print('both ENVIRONMENT =', self.get_setting('ENVIRONMENT')) |
| 8744 | test() |
| 8745 | |
| 8746 | @requires_node |
| 8747 | def test_postrun_exception(self): |
nothing calls this directly
no test coverage detected