Skip to content

Commit d97e83e

Browse files
committed
[test] Move requires_wasm2js to test/common.js. NFC
1 parent 72d980b commit d97e83e

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

test/common.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ def decorated(self, *args, **kwargs):
306306
return decorated
307307

308308

309+
def requires_wasm2js(f):
310+
assert callable(f)
311+
312+
@wraps(f)
313+
def decorated(self, *args, **kwargs):
314+
self.require_wasm2js()
315+
return f(self, *args, **kwargs)
316+
317+
return decorated
318+
319+
309320
def node_pthreads(f):
310321
@wraps(f)
311322
def decorated(self, *args, **kwargs):
@@ -373,7 +384,7 @@ def also_with_wasm_bigint(f):
373384

374385
def metafunc(self, with_bigint):
375386
if with_bigint:
376-
if not self.is_wasm():
387+
if self.is_wasm2js():
377388
self.skipTest('wasm2js does not support WASM_BIGINT')
378389
if self.get_setting('WASM_BIGINT') is not None:
379390
self.skipTest('redundant in bigint test config')
@@ -823,6 +834,12 @@ def require_jspi(self):
823834
else:
824835
self.fail('either d8 or node >= 19 required to run JSPI tests. Use EMTEST_SKIP_JSPI to skip')
825836

837+
def require_wasm2js(self):
838+
if self.is_wasm64():
839+
self.skipTest('wasm2js is not compatible with MEMORY64')
840+
if self.is_2gb() or self.is_4gb():
841+
self.skipTest('wasm2js does not support over 2gb of memory')
842+
826843
def setup_node_pthreads(self):
827844
self.require_node()
828845
self.emcc_args += ['-Wno-pthreads-mem-growth', '-pthread']

test/test_browser.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from common import BrowserCore, RunnerCore, path_from_root, has_browser, EMTEST_BROWSER, Reporting
2424
from common import create_file, parameterized, ensure_dir, disabled, test_file, WEBIDL_BINDER
2525
from common import read_file, also_with_minimal_runtime, EMRUN, no_wasm64, no_2gb, no_4gb
26+
from common import requires_wasm2js
2627
from tools import shared
2728
from tools import ports
2829
from tools import utils
@@ -185,17 +186,6 @@ def decorated(self, *args, **kwargs):
185186
return decorated
186187

187188

188-
def requires_wasm2js(f):
189-
assert callable(f)
190-
191-
@wraps(f)
192-
def decorated(self, *args, **kwargs):
193-
self.require_wasm2js()
194-
return f(self, *args, **kwargs)
195-
196-
return decorated
197-
198-
199189
def also_with_threads(f):
200190
assert callable(f)
201191

@@ -233,12 +223,6 @@ def setUp(self):
233223
'-Wno-int-conversion',
234224
]
235225

236-
def require_wasm2js(self):
237-
if self.is_wasm64():
238-
self.skipTest('wasm2js is not compatible with MEMORY64')
239-
if self.is_2gb() or self.is_4gb():
240-
self.skipTest('wasm2js does not support over 2gb of memory')
241-
242226
def require_jspi(self):
243227
if not is_chrome():
244228
self.skipTest(f'Current browser ({EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.')

test/test_core.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file
2727
from common import skip_if, needs_dylink, no_windows, no_mac, is_slow_test, parameterized
2828
from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint
29-
from common import read_file, read_binary, requires_v8, requires_node, requires_node_canary
29+
from common import read_file, read_binary, requires_v8, requires_node, requires_wasm2js, requires_node_canary
3030
from common import compiler_for, crossplatform, no_4gb, no_2gb
3131
from common import with_both_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64
3232
from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON
@@ -864,8 +864,8 @@ def test_emmalloc_memory_statistics(self):
864864
self.do_core_test('test_emmalloc_memory_statistics.c', out_suffix=out_suffix)
865865

866866
@no_optimize('output is sensitive to optimization flags, so only test unoptimized builds')
867-
@no_wasm64('output is sensitive to absolute data layout')
868867
@no_2gb('output is sensitive to absolute data layout')
868+
@no_4gb('output is sensitive to absolute data layout')
869869
@no_asan('ASan does not support custom memory allocators')
870870
@no_lsan('LSan does not support custom memory allocators')
871871
def test_emmalloc_trim(self):
@@ -8396,8 +8396,7 @@ def verify_broken(args):
83968396

83978397
# Test basic wasm2js functionality in all core compilation modes.
83988398
@no_sanitize('no wasm2js support yet in sanitizers')
8399-
@no_wasm64('no wasm2js support yet with wasm64')
8400-
@no_2gb('no wasm2js support for >2gb address space')
8399+
@requires_wasm2js
84018400
def test_wasm2js(self):
84028401
if not self.is_wasm():
84038402
self.skipTest('redundant to test wasm2js in wasm2js* mode')
@@ -8413,8 +8412,7 @@ def test_wasm2js(self):
84138412
self.assertNotExists('test_hello_world.js.mem')
84148413

84158414
@no_sanitize('no wasm2js support yet in sanitizers')
8416-
@no_wasm64('no wasm2js support yet with wasm64')
8417-
@no_2gb('no wasm2js support for >2gb address space')
8415+
@requires_wasm2js
84188416
def test_maybe_wasm2js(self):
84198417
if not self.is_wasm():
84208418
self.skipTest('redundant to test wasm2js in wasm2js* mode')
@@ -8432,7 +8430,7 @@ def test_maybe_wasm2js(self):
84328430
self.assertContained('hello, world!', self.run_js('do_wasm2js.js'))
84338431

84348432
@no_asan('no wasm2js support yet in asan')
8435-
@no_wasm64('no wasm2js support yet with wasm64')
8433+
@requires_wasm2js
84368434
@parameterized({
84378435
'': ([],),
84388436
'minimal_runtime': (['-sMINIMAL_RUNTIME'],),

0 commit comments

Comments
 (0)