Skip to content

Commit

Permalink
[test] Make more use of also_with_modularize. NFC (#23582)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Feb 4, 2025
1 parent ec40bc5 commit 1ddd294
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
14 changes: 14 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,20 @@ def metafunc(self, asan, *args, **kwargs):
return metafunc


def also_with_modularize(f):
assert callable(f)

@wraps(f)
def metafunc(self, modularize, *args, **kwargs):
if modularize:
self.emcc_args += ['--extern-post-js', test_file('modularize_post_js.js'), '-sMODULARIZE']
f(self, *args, **kwargs)

parameterize(metafunc, {'': (False,),
'modularize': (True,)})
return metafunc


# Tests exception handling and setjmp/longjmp handling. This tests three
# combinations:
# - Emscripten EH + Emscripten SjLj
Expand Down
39 changes: 11 additions & 28 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from common import skip_if, no_windows, no_mac, is_slow_test, parameterized, parameterize
from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint
from common import read_file, read_binary, requires_v8, requires_node, requires_wasm2js, requires_node_canary
from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime
from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime, also_with_modularize
from common import with_all_fs, also_with_nodefs, also_with_nodefs_both, also_with_noderawfs, also_with_wasmfs
from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64, requires_wasm_eh
from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON
Expand Down Expand Up @@ -2424,24 +2424,17 @@ def test_pthread_equal(self):
self.do_run_in_out_file_test('pthread/test_pthread_equal.cpp')

@node_pthreads
@parameterized({
'': (False,),
'modularize': (True,),
})
def test_pthread_proxying(self, modularize):
if modularize and self.get_setting('WASM') == 0:
self.skipTest('MODULARIZE + WASM=0 + pthreads does not work (#16794)')
@also_with_modularize
def test_pthread_proxying(self):
if '-sMODULARIZE' in self.emcc_args:
if self.get_setting('WASM') == 0:
self.skipTest('MODULARIZE + WASM=0 + pthreads does not work (#16794)')
self.set_setting('EXPORT_NAME=ModuleFactory')
self.maybe_closure()
self.set_setting('PROXY_TO_PTHREAD')
if not self.has_changed_setting('INITIAL_MEMORY'):
self.set_setting('INITIAL_MEMORY=32mb')
args = []
if modularize:
self.set_setting('MODULARIZE')
self.set_setting('EXPORT_NAME=ModuleFactory')
args = ['--extern-post-js', test_file('modularize_post_js.js')]
self.do_run_in_out_file_test('pthread/test_pthread_proxying.c',
interleaved_output=False, emcc_args=args)
self.do_run_in_out_file_test('pthread/test_pthread_proxying.c', interleaved_output=False)

@node_pthreads
def test_pthread_proxying_cpp(self):
Expand Down Expand Up @@ -9118,23 +9111,13 @@ def test_pthread_unhandledrejection(self):

@node_pthreads
@no_wasm2js('wasm2js does not support PROXY_TO_PTHREAD (custom section support)')
@also_with_modularize
def test_pthread_offset_converter(self):
self.set_setting('PROXY_TO_PTHREAD')
self.set_setting('EXIT_RUNTIME')
self.set_setting('USE_OFFSET_CONVERTER')
if '-g' in self.emcc_args:
self.emcc_args += ['-DDEBUG']
self.do_runf('core/test_return_address.c', 'passed')

@node_pthreads
@no_wasm2js('wasm2js does not support PROXY_TO_PTHREAD (custom section support)')
def test_pthread_offset_converter_modularize(self):
self.set_setting('PROXY_TO_PTHREAD')
self.set_setting('EXIT_RUNTIME')
self.set_setting('USE_OFFSET_CONVERTER')
self.set_setting('MODULARIZE')
self.set_setting('EXPORT_NAME', 'foo')
self.emcc_args += ['--extern-post-js', test_file('modularize_post_js.js')]
if '-sMODULARIZE' in self.emcc_args:
self.set_setting('EXPORT_NAME', 'foo')
if '-g' in self.emcc_args:
self.emcc_args += ['-DDEBUG']
self.do_runf('core/test_return_address.c', 'passed')
Expand Down
17 changes: 2 additions & 15 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
from common import create_file, parameterized, NON_ZERO, node_pthreads, TEST_ROOT, test_file
from common import compiler_for, EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary
from common import requires_wasm_eh, crossplatform, with_all_eh_sjlj, with_all_sjlj
from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs, also_with_wasmfs, with_all_fs
from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs
from common import also_with_modularize, also_with_wasmfs, with_all_fs
from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, also_with_asan, flaky
from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER
from common import requires_network, parameterize
Expand Down Expand Up @@ -124,20 +125,6 @@ def metafunc(self, backend, *args, **kwargs):
return metafunc


def also_with_modularize(f):
assert callable(f)

@wraps(f)
def metafunc(self, modularize, *args, **kwargs):
if modularize:
self.emcc_args += ['--extern-post-js', test_file('modularize_post_js.js'), '-sMODULARIZE']
f(self, *args, **kwargs)

parameterize(metafunc, {'': (False,),
'modularize': (True,)})
return metafunc


def also_with_wasmfs_all_backends(f):
assert callable(f)

Expand Down

0 comments on commit 1ddd294

Please sign in to comment.