From d97e83e9dd0fbfc4475221d50c41a3179d8c60ad Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 23 Feb 2024 10:25:48 -0800 Subject: [PATCH] [test] Move `requires_wasm2js` to `test/common.js`. NFC --- test/common.py | 19 ++++++++++++++++++- test/test_browser.py | 18 +----------------- test/test_core.py | 12 +++++------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/test/common.py b/test/common.py index 1c84c8e652b5..f2b59666c766 100644 --- a/test/common.py +++ b/test/common.py @@ -306,6 +306,17 @@ def decorated(self, *args, **kwargs): return decorated +def requires_wasm2js(f): + assert callable(f) + + @wraps(f) + def decorated(self, *args, **kwargs): + self.require_wasm2js() + return f(self, *args, **kwargs) + + return decorated + + def node_pthreads(f): @wraps(f) def decorated(self, *args, **kwargs): @@ -373,7 +384,7 @@ def also_with_wasm_bigint(f): def metafunc(self, with_bigint): if with_bigint: - if not self.is_wasm(): + if self.is_wasm2js(): self.skipTest('wasm2js does not support WASM_BIGINT') if self.get_setting('WASM_BIGINT') is not None: self.skipTest('redundant in bigint test config') @@ -823,6 +834,12 @@ def require_jspi(self): else: self.fail('either d8 or node >= 19 required to run JSPI tests. Use EMTEST_SKIP_JSPI to skip') + def require_wasm2js(self): + if self.is_wasm64(): + self.skipTest('wasm2js is not compatible with MEMORY64') + if self.is_2gb() or self.is_4gb(): + self.skipTest('wasm2js does not support over 2gb of memory') + def setup_node_pthreads(self): self.require_node() self.emcc_args += ['-Wno-pthreads-mem-growth', '-pthread'] diff --git a/test/test_browser.py b/test/test_browser.py index 34c8aae95956..0742152d2158 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -23,6 +23,7 @@ from common import BrowserCore, RunnerCore, path_from_root, has_browser, EMTEST_BROWSER, Reporting from common import create_file, parameterized, ensure_dir, disabled, test_file, WEBIDL_BINDER from common import read_file, also_with_minimal_runtime, EMRUN, no_wasm64, no_2gb, no_4gb +from common import requires_wasm2js from tools import shared from tools import ports from tools import utils @@ -185,17 +186,6 @@ def decorated(self, *args, **kwargs): return decorated -def requires_wasm2js(f): - assert callable(f) - - @wraps(f) - def decorated(self, *args, **kwargs): - self.require_wasm2js() - return f(self, *args, **kwargs) - - return decorated - - def also_with_threads(f): assert callable(f) @@ -233,12 +223,6 @@ def setUp(self): '-Wno-int-conversion', ] - def require_wasm2js(self): - if self.is_wasm64(): - self.skipTest('wasm2js is not compatible with MEMORY64') - if self.is_2gb() or self.is_4gb(): - self.skipTest('wasm2js does not support over 2gb of memory') - def require_jspi(self): if not is_chrome(): self.skipTest(f'Current browser ({EMTEST_BROWSER}) does not support JSPI. Only chromium-based browsers ({CHROMIUM_BASED_BROWSERS}) support JSPI today.') diff --git a/test/test_core.py b/test/test_core.py index f304f1366afd..1b9982571f34 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -26,7 +26,7 @@ from common import RunnerCore, path_from_root, requires_native_clang, test_file, create_file from common import skip_if, needs_dylink, no_windows, no_mac, is_slow_test, parameterized 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_node_canary +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 from common import with_both_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64 from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON @@ -864,8 +864,8 @@ def test_emmalloc_memory_statistics(self): self.do_core_test('test_emmalloc_memory_statistics.c', out_suffix=out_suffix) @no_optimize('output is sensitive to optimization flags, so only test unoptimized builds') - @no_wasm64('output is sensitive to absolute data layout') @no_2gb('output is sensitive to absolute data layout') + @no_4gb('output is sensitive to absolute data layout') @no_asan('ASan does not support custom memory allocators') @no_lsan('LSan does not support custom memory allocators') def test_emmalloc_trim(self): @@ -8396,8 +8396,7 @@ def verify_broken(args): # Test basic wasm2js functionality in all core compilation modes. @no_sanitize('no wasm2js support yet in sanitizers') - @no_wasm64('no wasm2js support yet with wasm64') - @no_2gb('no wasm2js support for >2gb address space') + @requires_wasm2js def test_wasm2js(self): if not self.is_wasm(): self.skipTest('redundant to test wasm2js in wasm2js* mode') @@ -8413,8 +8412,7 @@ def test_wasm2js(self): self.assertNotExists('test_hello_world.js.mem') @no_sanitize('no wasm2js support yet in sanitizers') - @no_wasm64('no wasm2js support yet with wasm64') - @no_2gb('no wasm2js support for >2gb address space') + @requires_wasm2js def test_maybe_wasm2js(self): if not self.is_wasm(): self.skipTest('redundant to test wasm2js in wasm2js* mode') @@ -8432,7 +8430,7 @@ def test_maybe_wasm2js(self): self.assertContained('hello, world!', self.run_js('do_wasm2js.js')) @no_asan('no wasm2js support yet in asan') - @no_wasm64('no wasm2js support yet with wasm64') + @requires_wasm2js @parameterized({ '': ([],), 'minimal_runtime': (['-sMINIMAL_RUNTIME'],),