Skip to content

Commit 238a09b

Browse files
authored
Unify also_with_wasmfs decorator. NFC (#22357)
This also means that also_with_wasmfs in test_core.py now used parameterization.
1 parent 02577a5 commit 238a09b

File tree

3 files changed

+20
-34
lines changed

3 files changed

+20
-34
lines changed

test/common.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,23 @@ def modified(self, *args, **kwargs):
363363
return decorated
364364

365365

366+
def also_with_wasmfs(f):
367+
assert callable(f)
368+
369+
@wraps(f)
370+
def metafunc(self, wasmfs, *args, **kwargs):
371+
if wasmfs:
372+
self.set_setting('WASMFS')
373+
self.emcc_args.append('-DWASMFS')
374+
f(self, *args, **kwargs)
375+
else:
376+
f(self, *args, **kwargs)
377+
378+
parameterize(metafunc, {'': (False,),
379+
'wasmfs': (True,)})
380+
return metafunc
381+
382+
366383
def also_with_noderawfs(func):
367384
assert callable(func)
368385

test/test_core.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
from common import skip_if, no_windows, no_mac, is_slow_test, parameterized, parameterize
2727
from common import env_modify, with_env_modify, disabled, flaky, node_pthreads, also_with_wasm_bigint
2828
from common import read_file, read_binary, requires_v8, requires_node, requires_wasm2js, requires_node_canary
29-
from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime, also_with_noderawfs
29+
from common import compiler_for, crossplatform, no_4gb, no_2gb, also_with_minimal_runtime
30+
from common import also_with_noderawfs, also_with_wasmfs
3031
from common import with_all_eh_sjlj, with_all_sjlj, also_with_standalone_wasm, can_do_standalone, no_wasm64, requires_wasm_exnref
3132
from common import NON_ZERO, WEBIDL_BINDER, EMBUILDER, PYTHON
3233
import clang_native
@@ -148,21 +149,6 @@ def decorated(f):
148149
return decorated
149150

150151

151-
def also_with_wasmfs(func):
152-
def decorated(self):
153-
func(self)
154-
if self.get_setting('WASMFS'):
155-
# Nothing more to test.
156-
return
157-
print('wasmfs')
158-
if self.get_setting('STANDALONE_WASM'):
159-
self.skipTest("test currently cannot run both with WASMFS and STANDALONE_WASM")
160-
self.set_setting('WASMFS')
161-
self.emcc_args = self.emcc_args.copy() + ['-DWASMFS']
162-
func(self)
163-
return decorated
164-
165-
166152
# Similar to also_with_wasmfs, but also enables the full JS API
167153
def also_with_wasmfs_js(func):
168154
def decorated(self):

test/test_other.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from common import create_file, parameterized, NON_ZERO, node_pthreads, TEST_ROOT, test_file
3737
from common import compiler_for, EMBUILDER, requires_v8, requires_node, requires_wasm64, requires_node_canary
3838
from common import requires_wasm_exnref, crossplatform, with_all_eh_sjlj, with_all_sjlj
39-
from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs
39+
from common import also_with_standalone_wasm, also_with_wasm2js, also_with_noderawfs, also_with_wasmfs
4040
from common import also_with_minimal_runtime, also_with_wasm_bigint, also_with_wasm64, flaky
4141
from common import EMTEST_BUILD_VERBOSE, PYTHON, WEBIDL_BINDER
4242
from common import requires_network, parameterize
@@ -110,23 +110,6 @@ def with_both_compilers(f):
110110
return f
111111

112112

113-
def also_with_wasmfs(f):
114-
assert callable(f)
115-
116-
@wraps(f)
117-
def metafunc(self, wasmfs, *args, **kwargs):
118-
if wasmfs:
119-
self.set_setting('WASMFS')
120-
self.emcc_args.append('-DWASMFS')
121-
f(self, *args, **kwargs)
122-
else:
123-
f(self, *args, **kwargs)
124-
125-
parameterize(metafunc, {'': (False,),
126-
'wasmfs': (True,)})
127-
return metafunc
128-
129-
130113
def wasmfs_all_backends(f):
131114
def metafunc(self, backend):
132115
self.set_setting('WASMFS')

0 commit comments

Comments
 (0)