Skip to content

Commit 58a03c7

Browse files
authored
Cleanup test_async_compile. NFC (#21259)
1 parent 6cdb695 commit 58a03c7

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

test/browser/test_async_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ int main() {
1414
int result = EM_ASM_INT({
1515
return Module.sawAsyncCompilation | 0;
1616
});
17+
printf("sawAsyncCompilation => %d\n", result);
1718
return result;
1819
}
1920

test/test_browser.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4467,7 +4467,16 @@ def test_in_flight_memfile_request(self, args, expected):
44674467
# should happen when there is a mem init file (-O2+)
44684468
self.btest('in_flight_memfile_request.c', expected=expected)
44694469

4470-
def test_async_compile(self):
4470+
@parameterized({
4471+
'': ([], 1),
4472+
'O1': (['-O1'], 1),
4473+
'O2': (['-O2'], 1),
4474+
'O3': (['-O3'], 1),
4475+
# force it on
4476+
'force': (['-sWASM_ASYNC_COMPILATION'], 1),
4477+
'off': (['-sWASM_ASYNC_COMPILATION=0'], 0),
4478+
})
4479+
def test_async_compile(self, opts, returncode):
44714480
# notice when we use async compilation
44724481
script = '''
44734482
<script>
@@ -4476,11 +4485,13 @@ def test_async_compile(self):
44764485
var real_wasm_instantiateStreaming = WebAssembly.instantiateStreaming;
44774486
if (typeof real_wasm_instantiateStreaming === 'function') {
44784487
WebAssembly.instantiateStreaming = (a, b) => {
4488+
console.log('instantiateStreaming called');
44794489
Module.sawAsyncCompilation = true;
44804490
return real_wasm_instantiateStreaming(a, b);
44814491
};
44824492
} else {
44834493
WebAssembly.instantiate = (a, b) => {
4494+
console.log('instantiate called');
44844495
Module.sawAsyncCompilation = true;
44854496
return real_wasm_instantiate(a, b);
44864497
};
@@ -4495,21 +4506,9 @@ def test_async_compile(self):
44954506
'''
44964507
shell_with_script('shell.html', 'shell.html', script)
44974508
common_args = ['--shell-file', 'shell.html']
4498-
for opts, returncode in [
4499-
([], 1),
4500-
(['-O1'], 1),
4501-
(['-O2'], 1),
4502-
(['-O3'], 1),
4503-
# force it on
4504-
(['-sWASM_ASYNC_COMPILATION'], 1),
4505-
# force it off. note that we use -O3 here to make the binary small enough
4506-
# for chrome to allow compiling it synchronously
4507-
(['-O3', '-sWASM_ASYNC_COMPILATION=0'], 0),
4508-
]:
4509-
print(opts, returncode)
4510-
self.btest_exit('test_async_compile.c', assert_returncode=returncode, args=common_args + opts)
4509+
self.btest_exit('test_async_compile.c', assert_returncode=returncode, args=common_args + opts)
45114510
# Ensure that compilation still works and is async without instantiateStreaming available
4512-
no_streaming = ' <script> WebAssembly.instantiateStreaming = undefined;</script>'
4511+
no_streaming = '<script>WebAssembly.instantiateStreaming = undefined;</script>'
45134512
shell_with_script('shell.html', 'shell.html', no_streaming + script)
45144513
self.btest_exit('test_async_compile.c', assert_returncode=1, args=common_args)
45154514

0 commit comments

Comments
 (0)