Skip to content

Commit 54ef4c6

Browse files
authored
Add @requires_wasm_workers decorator. NFC (emscripten-core#26652)
This avoids repeating the same set of decorators all over the place.
1 parent 339a66f commit 54ef4c6

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

test/test_core.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ def decorated(self, *args, **kwargs):
161161
return decorated
162162

163163

164+
def requires_wasm_workers(func):
165+
assert callable(func)
166+
167+
@wraps(func)
168+
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
169+
@no_sanitize('sanitizers do not support WASM_WORKERS')
170+
def decorated(self, *args, **kwargs):
171+
return func(self, *args, **kwargs)
172+
173+
return decorated
174+
175+
164176
def wasm_relaxed_simd(func):
165177
assert callable(func)
166178

@@ -287,13 +299,11 @@ def also_with_wasm_workers(func):
287299

288300
@wraps(func)
289301
def metafunc(self, ww, *args, **kwargs):
302+
f = func
290303
if ww:
291-
if self.get_setting('WASM_ESM_INTEGRATION'):
292-
self.skipTest('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
293-
if is_sanitizing(self.cflags):
294-
self.skipTest('sanitizers are not compatible with WASM_WORKERS')
304+
f = requires_wasm_workers(f)
295305
self.cflags += ['-sWASM_WORKERS']
296-
return func(self, *args, **kwargs)
306+
return f(self, *args, **kwargs)
297307

298308
parameterize(metafunc, {'': (False,), 'ww': (True,)})
299309
return metafunc
@@ -991,8 +1001,7 @@ def test_longjmp_standalone(self):
9911001
def test_longjmp(self):
9921002
self.do_core_test('test_longjmp.c')
9931003

994-
@no_sanitize('sanitizers do not support WASM_WORKERS')
995-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
1004+
@requires_wasm_workers
9961005
def test_longjmp_wasm_workers(self):
9971006
self.do_core_test('test_longjmp.c', cflags=['-sWASM_WORKERS'])
9981007

@@ -7770,8 +7779,7 @@ def test_embind_no_rtti_followed_by_rtti(self):
77707779
'''
77717780
self.do_run(src, '418\ndotest returned: 42\n', cflags=['-lembind', '-fno-rtti', '-frtti'])
77727781

7773-
@no_sanitize('sanitizers do not support WASM_WORKERS')
7774-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
7782+
@requires_wasm_workers
77757783
def test_embind_wasm_workers(self):
77767784
self.do_run_in_out_file_test('embind/test_embind_wasm_workers.cpp', cflags=['-lembind', '-sWASM_WORKERS'])
77777785

@@ -9259,8 +9267,7 @@ def test_emscripten_futex_api_basics(self):
92599267
def test_stdio_locking(self):
92609268
self.do_core_test('test_stdio_locking.c', cflags=['-sPTHREAD_POOL_SIZE=2'])
92619269

9262-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
9263-
@no_sanitize('sanitizers do not support WASM_WORKERS')
9270+
@requires_wasm_workers
92649271
def test_stdio_locking_ww(self):
92659272
# Note: do not combine with test_stdio_locking above because we want to test standalone
92669273
# wasm workers here and `@requires_pthreads` would prevent that.
@@ -9697,33 +9704,28 @@ def test_emscripten_async_load_script(self):
96979704
self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'file1.txt', 'file2.txt', '--from-emcc', '--js-output=script2.js'])
96989705
self.do_runf('test_emscripten_async_load_script.c', cflags=['-sFORCE_FILESYSTEM'])
96999706

9700-
@no_sanitize('sanitizers do not support WASM_WORKERS')
97019707
@also_with_minimal_runtime
97029708
@also_with_modularize
9703-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
9709+
@requires_wasm_workers
97049710
def test_wasm_worker_hello(self):
97059711
if self.is_wasm2js() and '-sMODULARIZE' in self.cflags:
97069712
self.skipTest('WASM2JS + MODULARIZE + WASM_WORKERS is not supported')
97079713
self.maybe_closure()
97089714
self.do_run_in_out_file_test('wasm_worker/hello_wasm_worker.c', cflags=['-sWASM_WORKERS'])
97099715

9710-
@no_sanitize('sanitizers do not support WASM_WORKERS')
9711-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
9716+
@requires_wasm_workers
97129717
def test_wasm_worker_malloc(self):
97139718
self.do_run_in_out_file_test('wasm_worker/malloc_wasm_worker.c', cflags=['-sWASM_WORKERS'])
97149719

9715-
@no_sanitize('sanitizers do not support WASM_WORKERS')
9716-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
9720+
@requires_wasm_workers
97179721
def test_wasm_worker_runtime_debug(self):
97189722
self.do_runf('wasm_worker/hello_wasm_worker.c', 'wasm worker starting ...', cflags=['-sWASM_WORKERS', '-sRUNTIME_DEBUG'])
97199723

9720-
@no_sanitize('sanitizers do not support WASM_WORKERS')
9721-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
9724+
@requires_wasm_workers
97229725
def test_wasm_worker_futex_wait(self):
97239726
self.do_runf('wasm_worker/wasm_worker_futex_wait.c', cflags=['-sWASM_WORKERS'])
97249727

9725-
@no_sanitize('sanitizers do not support WASM_WORKERS')
9726-
@no_esm_integration('WASM_ESM_INTEGRATION is not compatible with WASM_WORKERS')
9728+
@requires_wasm_workers
97279729
def test_wasm_worker_wait_async(self):
97289730
self.do_runf('atomic/test_wait_async.c', cflags=['-sWASM_WORKERS'])
97299731

0 commit comments

Comments
 (0)