Skip to content

Commit ff099ef

Browse files
committed
Use @parmeterize in more browser tests. NFC
1 parent fe8421d commit ff099ef

File tree

2 files changed

+71
-47
lines changed

2 files changed

+71
-47
lines changed

test/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ def modified(self, *args, **kwargs):
354354
def also_with_minimal_runtime(f):
355355
assert callable(f)
356356

357-
def metafunc(self, with_minimal_runtime):
357+
def metafunc(self, with_minimal_runtime, *args, **kwargs):
358358
assert self.get_setting('MINIMAL_RUNTIME') is None
359359
if with_minimal_runtime:
360360
self.set_setting('MINIMAL_RUNTIME', 1)
361-
f(self)
361+
f(self, *args, **kwargs)
362362

363363
metafunc._parameterize = {'': (False,),
364364
'minimal_runtime': (True,)}

test/test_browser.py

Lines changed: 69 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,12 +1375,15 @@ def test_write_file_in_environment_web(self):
13751375
def test_fflush(self):
13761376
self.btest('test_fflush.cpp', '0', args=['-sEXIT_RUNTIME', '--shell-file', test_file('test_fflush.html')], reporting=Reporting.NONE)
13771377

1378-
def test_fs_idbfs_sync(self):
1378+
@parameterized({
1379+
'': ([],),
1380+
'extra': (['-DEXTRA_WORK'],),
1381+
})
1382+
def test_fs_idbfs_sync(self, extra):
13791383
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
1380-
for extra in [[], ['-DEXTRA_WORK']]:
1381-
secret = str(time.time())
1382-
self.btest('fs/test_idbfs_sync.c', '1', args=['-lidbfs.js', '-DFIRST', f'-DSECRET="{secret}"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'])
1383-
self.btest('fs/test_idbfs_sync.c', '1', args=['-lidbfs.js', f'-DSECRET="{secret }"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'] + extra)
1384+
secret = str(time.time())
1385+
self.btest('fs/test_idbfs_sync.c', '1', args=['-lidbfs.js', '-DFIRST', f'-DSECRET="{secret}"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'])
1386+
self.btest('fs/test_idbfs_sync.c', '1', args=['-lidbfs.js', f'-DSECRET="{secret }"', '-sEXPORTED_FUNCTIONS=_main,_test,_success', '-lidbfs.js'] + extra)
13841387

13851388
def test_fs_idbfs_sync_force_exit(self):
13861389
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
@@ -1800,16 +1803,19 @@ def test_glgears_long(self, args):
18001803
self.btest('hello_world_gles.c', expected='0', args=args)
18011804

18021805
@requires_graphics_hardware
1803-
def test_glgears_animation(self):
1804-
for filename in ['hello_world_gles.c', 'hello_world_gles_full.c', 'hello_world_gles_full_944.c']:
1805-
print(filename)
1806-
args = ['-o', 'something.html',
1807-
'-DHAVE_BUILTIN_SINCOS', '-sGL_TESTING', '-lGL', '-lglut',
1808-
'--shell-file', test_file('hello_world_gles_shell.html')]
1809-
if 'full' in filename:
1810-
args += ['-sFULL_ES2']
1811-
self.compile_btest(filename, args)
1812-
self.run_browser('something.html', '/report_gl_result?true')
1806+
@parameterized({
1807+
'': ('hello_world_gles.c',),
1808+
'full': ('hello_world_gles_full.c',),
1809+
'full_944': ('hello_world_gles_full_944.c',),
1810+
})
1811+
def test_glgears_animation(self, filename):
1812+
args = ['-o', 'something.html',
1813+
'-DHAVE_BUILTIN_SINCOS', '-sGL_TESTING', '-lGL', '-lglut',
1814+
'--shell-file', test_file('hello_world_gles_shell.html')]
1815+
if 'full' in filename:
1816+
args += ['-sFULL_ES2']
1817+
self.compile_btest(filename, args)
1818+
self.run_browser('something.html', '/report_gl_result?true')
18131819

18141820
@requires_graphics_hardware
18151821
def test_fulles2_sdlproc(self):
@@ -2712,27 +2718,37 @@ def test_html5_core(self, opts):
27122718
self.btest_exit('test_html5_core.c', args=opts)
27132719

27142720
@requires_threads
2715-
def test_html5_gamepad(self):
2716-
for opts in [[], ['-O2', '-g1', '--closure=1'], ['-pthread', '-sPROXY_TO_PTHREAD']]:
2717-
print(opts)
2718-
self.btest_exit('test_gamepad.c', args=[] + opts)
2721+
@parameterized({
2722+
'': ([],),
2723+
'closure': (['-O2', '-g1', '--closure=1'],),
2724+
'pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
2725+
})
2726+
def test_html5_gamepad(self, args):
2727+
self.btest_exit('test_gamepad.c', args=args)
27192728

27202729
def test_html5_unknown_event_target(self):
27212730
self.btest_exit('test_html5_unknown_event_target.cpp')
27222731

27232732
@requires_graphics_hardware
2724-
def test_html5_webgl_create_context_no_antialias(self):
2725-
for opts in [[], ['-O2', '-g1', '--closure=1'], ['-sFULL_ES2']]:
2726-
print(opts)
2727-
self.btest_exit('webgl_create_context.cpp', args=opts + ['-DNO_ANTIALIAS', '-lGL'])
2733+
@parameterized({
2734+
'': ([],),
2735+
'closure': (['-O2', '-g1', '--closure=1'],),
2736+
'full_es2': (['-sFULL_ES2'],),
2737+
})
2738+
def test_html5_webgl_create_context_no_antialias(self, args):
2739+
self.btest_exit('webgl_create_context.cpp', args=args + ['-DNO_ANTIALIAS', '-lGL'])
27282740

27292741
# This test supersedes the one above, but it's skipped in the CI because anti-aliasing is not well supported by the Mesa software renderer.
27302742
@requires_threads
27312743
@requires_graphics_hardware
2732-
def test_html5_webgl_create_context(self):
2733-
for opts in [[], ['-O2', '-g1', '--closure=1'], ['-sFULL_ES2'], ['-pthread']]:
2734-
print(opts)
2735-
self.btest_exit('webgl_create_context.cpp', args=opts + ['-lGL'])
2744+
@parameterized({
2745+
'': ([],),
2746+
'closure': (['-O2', '-g1', '--closure=1'],),
2747+
'full_es2': (['-sFULL_ES2'],),
2748+
'pthread': (['-pthread'],),
2749+
})
2750+
def test_html5_webgl_create_context(self, args):
2751+
self.btest_exit('webgl_create_context.cpp', args=args + ['-lGL'])
27362752

27372753
@requires_graphics_hardware
27382754
# Verify bug https://github.com/emscripten-core/emscripten/issues/4556: creating a WebGL context to Module.canvas without an ID explicitly assigned to it.
@@ -4095,9 +4111,12 @@ def test_pthread_cleanup(self):
40954111

40964112
# Tests the pthread mutex api.
40974113
@requires_threads
4098-
def test_pthread_mutex(self):
4099-
for arg in [[], ['-DSPINLOCK_TEST']]:
4100-
self.btest_exit('pthread/test_pthread_mutex.cpp', args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + arg)
4114+
@parameterized({
4115+
'': ([],),
4116+
'spinlock': (['-DSPINLOCK_TEST'],),
4117+
})
4118+
def test_pthread_mutex(self, args):
4119+
self.btest_exit('pthread/test_pthread_mutex.cpp', args=['-sINITIAL_MEMORY=64MB', '-O3', '-pthread', '-sPTHREAD_POOL_SIZE=8'] + args)
41014120

41024121
@requires_threads
41034122
def test_pthread_attr_getstack(self):
@@ -5069,22 +5088,25 @@ def test_single_file_html(self):
50695088
self.assertNotExists('test.mem')
50705089

50715090
# Tests that SINGLE_FILE works as intended in generated HTML with MINIMAL_RUNTIME
5091+
@parameterized({
5092+
'': ([],),
5093+
'O3': (['-O3'],)
5094+
})
50725095
@parameterized({
50735096
'': ([],),
50745097
'wasm2js': (['-sWASM=0'],)
50755098
})
5076-
def test_minimal_runtime_single_file_html(self, args):
5077-
if args:
5099+
def test_minimal_runtime_single_file_html(self, args, opts):
5100+
if '-sWASM=0' in args:
50785101
self.require_wasm2js()
5079-
for opts in [[], ['-O3']]:
5080-
self.btest('single_file_static_initializer.cpp', '19', args=opts + args + ['-sMINIMAL_RUNTIME', '-sSINGLE_FILE'])
5081-
self.assertExists('test.html')
5082-
self.assertNotExists('test.js')
5083-
self.assertNotExists('test.wasm')
5084-
self.assertNotExists('test.asm.js')
5085-
self.assertNotExists('test.mem')
5086-
self.assertNotExists('test.js')
5087-
self.assertNotExists('test.worker.js')
5102+
self.btest('single_file_static_initializer.cpp', '19', args=opts + args + ['-sMINIMAL_RUNTIME', '-sSINGLE_FILE'])
5103+
self.assertExists('test.html')
5104+
self.assertNotExists('test.js')
5105+
self.assertNotExists('test.wasm')
5106+
self.assertNotExists('test.asm.js')
5107+
self.assertNotExists('test.mem')
5108+
self.assertNotExists('test.js')
5109+
self.assertNotExists('test.worker.js')
50885110

50895111
# Tests that SINGLE_FILE works when built with ENVIRONMENT=web and Closure enabled (#7933)
50905112
def test_single_file_in_web_environment_with_closure(self):
@@ -5316,18 +5338,20 @@ def test_no_declare_asm_module_exports_wasm_minimal_runtime(self, mode):
53165338
self.btest_exit('declare_asm_module_exports.c', args=['-sDECLARE_ASM_MODULE_EXPORTS=0', '-sENVIRONMENT=web', '-O3', '--closure=1', f'-sMINIMAL_RUNTIME={mode}'])
53175339

53185340
# Tests that the different code paths in src/shell_minimal_runtime.html all work ok.
5341+
@parameterized({
5342+
'': ([],),
5343+
'modularize': (['-sMODULARIZE'],),
5344+
})
53195345
@parameterized({
53205346
'': ([],),
53215347
'wasm2js': (['-sWASM=0', '--memory-init-file', '0'],),
53225348
'wasm2js_mem_init_file': (['-sWASM=0', '--memory-init-file', '1'],),
53235349
})
5324-
def test_minimal_runtime_loader_shell(self, wasm_args):
5350+
def test_minimal_runtime_loader_shell(self, wasm_args, modularize):
53255351
args = ['-sMINIMAL_RUNTIME=2']
53265352
if wasm_args:
53275353
self.require_wasm2js()
5328-
for modularize in [[], ['-sMODULARIZE']]:
5329-
print(str(modularize))
5330-
self.btest_exit('minimal_hello.c', args=args + wasm_args + modularize)
5354+
self.btest_exit('minimal_hello.c', args=args + wasm_args + modularize)
53315355

53325356
# Tests that -sMINIMAL_RUNTIME works well in different build modes
53335357
@parameterized({

0 commit comments

Comments
 (0)