Skip to content

Commit c1b2a42

Browse files
committed
Inject minimal_runtime_exit_handling.js as part of also_with_minimal_runtime. NFC
This allows `also_with_minimal_runtime` to be used in more places removing a bunch of duplication.
1 parent 11e3111 commit c1b2a42

File tree

2 files changed

+14
-41
lines changed

2 files changed

+14
-41
lines changed

test/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ def metafunc(self, with_minimal_runtime, *args, **kwargs):
504504
assert self.get_setting('MINIMAL_RUNTIME') is None
505505
if with_minimal_runtime:
506506
self.set_setting('MINIMAL_RUNTIME', 1)
507+
# This extra helper code is needed to cleanly handle calls to exit() which throw
508+
# an ExitCode exception.
509+
self.emcc_args += ['--pre-js', test_file('minimal_runtime_exit_handling.js')]
507510
f(self, *args, **kwargs)
508511

509512
parameterize(metafunc, {'': (False,),

test/test_core.py

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5596,23 +5596,14 @@ def test_utf8_textdecoder(self):
55965596
self.do_runf('benchmark/benchmark_utf8.c', 'OK.')
55975597

55985598
# Test that invalid character in UTF8 does not cause decoding to crash.
5599+
@also_with_minimal_runtime
55995600
@parameterized({
5600-
'': [[]],
5601-
'textdecoder': [['-sTEXTDECODER']],
5601+
'': ([],),
5602+
'textdecoder': (['-sTEXTDECODER'],),
56025603
})
56035604
def test_utf8_invalid(self, args):
56045605
self.do_runf('test_utf8_invalid.c', 'OK.', emcc_args=args)
56055606

5606-
# Test that invalid character in UTF8 does not cause decoding to crash.
5607-
@parameterized({
5608-
'': [[]],
5609-
'textdecoder': [['-sTEXTDECODER']],
5610-
})
5611-
def test_minimal_runtime_utf8_invalid(self, args):
5612-
self.set_setting('MINIMAL_RUNTIME')
5613-
self.emcc_args += ['--pre-js', test_file('minimal_runtime_exit_handling.js')]
5614-
self.do_runf('test_utf8_invalid.c', 'OK.', emcc_args=args)
5615-
56165607
def test_utf16_textdecoder(self):
56175608
self.emcc_args += ['--embed-file', test_file('utf16_corpus.txt') + '@/utf16_corpus.txt']
56185609
self.do_runf('benchmark/benchmark_utf16.cpp', 'OK.')
@@ -6929,34 +6920,29 @@ def test_EXPORTED_RUNTIME_METHODS(self):
69296920
self.set_setting('EXPORTED_RUNTIME_METHODS', ['dynCall', 'addFunction', 'lengthBytesUTF8', 'getTempRet0', 'setTempRet0'])
69306921
self.do_core_test('EXPORTED_RUNTIME_METHODS.c')
69316922

6932-
@parameterized({
6933-
'': [],
6934-
'minimal_runtime': ['-sMINIMAL_RUNTIME=1']
6935-
})
6936-
def test_dyncall_specific(self, *args):
6923+
@also_with_minimal_runtime
6924+
def test_dyncall_specific(self):
69376925
if self.get_setting('MEMORY64'):
69386926
self.skipTest('not compatible with MEMORY64')
69396927
if self.get_setting('WASM_BIGINT') != 0 and not self.is_wasm2js():
69406928
# define DYNCALLS because this test does test calling them directly, and
69416929
# in WASM_BIGINT mode we do not enable them by default (since we can do
69426930
# more without them - we don't need to legalize)
6943-
args = list(args) + ['-sDYNCALLS', '-DWASM_BIGINT']
6931+
self.emcc_args += ['-sDYNCALLS', '-DWASM_BIGINT']
69446932
cases = [
69456933
('DIRECT', []),
69466934
('DYNAMIC_SIG', ['-sDYNCALLS']),
69476935
]
6948-
if '-sMINIMAL_RUNTIME=1' in args:
6949-
self.emcc_args += ['--pre-js', test_file('minimal_runtime_exit_handling.js')]
6950-
else:
6936+
if self.get_setting('MINIMAL_RUNTIME') == 0:
69516937
cases += [
69526938
('EXPORTED', []),
69536939
('EXPORTED_DYNAMIC_SIG', ['-sDYNCALLS', '-sEXPORTED_RUNTIME_METHODS=dynCall']),
69546940
('FROM_OUTSIDE', ['-sEXPORTED_RUNTIME_METHODS=dynCall_iiji'])
69556941
]
69566942

69576943
for which, extra_args in cases:
6958-
print(str(args) + ' ' + which)
6959-
self.do_core_test('test_dyncall_specific.c', emcc_args=['-D' + which] + list(args) + extra_args)
6944+
print(str(extra_args) + ' ' + which)
6945+
self.do_core_test('test_dyncall_specific.c', emcc_args=['-D' + which] + extra_args)
69606946

69616947
@parameterized({
69626948
'': ([],),
@@ -8600,6 +8586,7 @@ def test_postrun_exit_runtime(self):
86008586
self.do_runf('hello_world.c', 'post run')
86018587

86028588
# Tests that building with -sDECLARE_ASM_MODULE_EXPORTS=0 works
8589+
@also_with_minimal_runtime
86038590
def test_no_declare_asm_module_exports(self):
86048591
self.set_setting('DECLARE_ASM_MODULE_EXPORTS', 0)
86058592
self.set_setting('WASM_ASYNC_COMPILATION', 0)
@@ -8617,16 +8604,6 @@ def test_no_declare_asm_module_exports(self):
86178604
else:
86188605
print(occurances)
86198606

8620-
# Tests that building with -sDECLARE_ASM_MODULE_EXPORTS=0 works
8621-
@no_wasmfs('https://github.com/emscripten-core/emscripten/issues/16816')
8622-
def test_minimal_runtime_no_declare_asm_module_exports(self):
8623-
self.set_setting('DECLARE_ASM_MODULE_EXPORTS', 0)
8624-
self.set_setting('WASM_ASYNC_COMPILATION', 0)
8625-
self.maybe_closure()
8626-
self.set_setting('MINIMAL_RUNTIME')
8627-
self.emcc_args += ['--pre-js', test_file('minimal_runtime_exit_handling.js')]
8628-
self.do_runf('declare_asm_module_exports.c', 'jsFunction: 1')
8629-
86308607
# Tests that -sMINIMAL_RUNTIME works well in different build modes
86318608
@no_wasmfs('https://github.com/emscripten-core/emscripten/issues/16816')
86328609
@parameterized({
@@ -9354,19 +9331,12 @@ def test_Module_dynamicLibraries(self, args):
93549331
force_c=True)
93559332

93569333
# Tests the emscripten_get_exported_function() API.
9334+
@also_with_minimal_runtime
93579335
def test_get_exported_function(self):
93589336
self.set_setting('ALLOW_TABLE_GROWTH')
93599337
self.emcc_args += ['-lexports.js']
93609338
self.do_core_test('test_get_exported_function.cpp')
93619339

9362-
# Tests the emscripten_get_exported_function() API.
9363-
def test_minimal_runtime_get_exported_function(self):
9364-
self.set_setting('ALLOW_TABLE_GROWTH')
9365-
self.set_setting('MINIMAL_RUNTIME')
9366-
self.emcc_args += ['--pre-js', test_file('minimal_runtime_exit_handling.js')]
9367-
self.emcc_args += ['-lexports.js']
9368-
self.do_core_test('test_get_exported_function.cpp')
9369-
93709340
# Marked as impure since the WASI reactor modules (modules without main)
93719341
# are not yet suppored by the wasm engines we test against.
93729342
@also_with_standalone_wasm(impure=True)

0 commit comments

Comments
 (0)