Skip to content

Commit

Permalink
JSPI - Cleanup up testing code. (emscripten-core#19837)
Browse files Browse the repository at this point in the history
- Automatically suppress the experimental warning when using require_jspi
 - Use require_jspi instead of require_v8 in more places
  • Loading branch information
brendandahl authored Jul 12, 2023
1 parent 68ee2af commit a3fd28f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
4 changes: 4 additions & 0 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ def require_wasm_eh(self):
self.fail('either d8 or node >= 17 required to run wasm-eh tests. Use EMTEST_SKIP_EH to skip')

def require_jspi(self):
# emcc warns about stack switching being experimental, and we build with
# warnings-as-errors, so disable that warning
self.emcc_args += ['-Wno-experimental']
self.emcc_args += ['-sASYNCIFY=2']
if not self.is_wasm():
self.skipTest('JSPI is not currently supported for WASM2JS')

Expand Down
12 changes: 2 additions & 10 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,6 @@ def metafunc(self, jspi):
if jspi:
self.set_setting('ASYNCIFY', 2)
self.require_jspi()
if not self.is_wasm():
self.skipTest('wasm2js does not support WebAssembly.Suspender yet')
# emcc warns about stack switching being experimental, and we build with
# warnings-as-errors, so disable that warning
self.emcc_args += ['-Wno-experimental']
f(self)
else:
self.set_setting('ASYNCIFY')
Expand Down Expand Up @@ -8253,7 +8248,6 @@ def test_async_ccall_good(self):
def test_async_ccall_promise(self, exit_runtime, asyncify):
if asyncify == 2:
self.require_jspi()
self.emcc_args += ['-Wno-experimental']
self.set_setting('ASYNCIFY_EXPORTS', ['stringf', 'floatf'])
self.set_setting('ASYNCIFY', asyncify)
self.set_setting('EXIT_RUNTIME')
Expand Down Expand Up @@ -8431,11 +8425,9 @@ def test_pthread_join_and_asyncify(self):
# TODO Test with ASYNCIFY=1 https://github.com/emscripten-core/emscripten/issues/17552
self.require_jspi()
self.do_runf(test_file('core/test_pthread_join_and_asyncify.c'), 'joining thread!\njoined thread!',
emcc_args=['-sASYNCIFY=2',
'-sASYNCIFY_EXPORTS=run_thread',
emcc_args=['-sASYNCIFY_EXPORTS=run_thread',
'-sEXIT_RUNTIME=1',
'-pthread', '-sPROXY_TO_PTHREAD',
'-Wno-experimental'])
'-pthread', '-sPROXY_TO_PTHREAD'])

@no_asan('asyncify stack operations confuse asan')
@no_wasm64('TODO: asyncify for wasm64')
Expand Down
19 changes: 7 additions & 12 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2745,9 +2745,8 @@ def test_embind_asyncify(self):
'no_dynamic': ['-sDYNAMIC_EXECUTION=0'],
})
def test_embind_jspi(self, extra):
self.require_v8()
self.v8_args.append('--experimental-wasm-stack-switching')
self.emcc_args += ['-lembind', '-g', '-sASYNCIFY=2', '-Wno-experimental']
self.require_jspi()
self.emcc_args += ['-lembind', '-g']
self.emcc_args += [extra]

self.do_runf(test_file('embind/embind_jspi_test.cpp'), 'done')
Expand Down Expand Up @@ -2870,9 +2869,8 @@ def test_embind_finalization(self):
self.assertNotContained('Foo* destructed', output)

def test_jspi_wildcard(self):
self.require_v8()
self.v8_args.append('--experimental-wasm-stack-switching')
self.emcc_args += ['-sASYNCIFY=2', '-sASYNCIFY_EXPORTS=async*', '-Wno-experimental']
self.require_jspi()
self.emcc_args += ['-sASYNCIFY_EXPORTS=async*']

self.do_runf(test_file('other/test_jspi_wildcard.c'), 'done')

Expand Down Expand Up @@ -6685,9 +6683,7 @@ def test_dlopen_blocking(self, asyncify):
if asyncify:
self.set_setting('ASYNCIFY', asyncify)
if asyncify == 2:
self.emcc_args.append('-Wno-experimental')
self.require_v8()
self.v8_args.append('--experimental-wasm-stack-switching')
self.require_jspi()
self.emcc_args.append('libside.so')
self.do_other_test('test_dlopen_blocking.c')

Expand Down Expand Up @@ -11821,9 +11817,8 @@ def test_split_module(self, customLoader, jspi):
if customLoader:
self.emcc_args += ['--pre-js', test_file('other/test_load_split_module.pre.js')]
if jspi:
self.require_v8()
self.v8_args.append('--experimental-wasm-stack-switching')
self.emcc_args += ['-g', '-sASYNCIFY=2', '-sASYNCIFY_EXPORTS=[\'say_hello\']']
self.require_jspi()
self.emcc_args += ['-g', '-sASYNCIFY_EXPORTS=[\'say_hello\']']
self.emcc_args += ['-sEXPORTED_FUNCTIONS=_malloc,_free']
output = self.do_other_test('test_split_module.c')
if jspi:
Expand Down

0 comments on commit a3fd28f

Please sign in to comment.