Skip to content

Commit

Permalink
[test] Move requires_wasm2js to test/common.js. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Feb 23, 2024
1 parent 72d980b commit d97e83e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
19 changes: 18 additions & 1 deletion test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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']
Expand Down
18 changes: 1 addition & 17 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.')
Expand Down
12 changes: 5 additions & 7 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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'],),
Expand Down

0 comments on commit d97e83e

Please sign in to comment.