Skip to content

Commit e44f382

Browse files
authored
Fix combining of test parametization. NFC (#22637)
As far as I can tell the only test that was relying on this features is `browser.test_sdl_image_prepare` which uses `@also_with_proxied` in addition to `@also_with_wasmfs` and it was getting the names and values backwards. I confirmed manually that all 4 test combination now do the right thing.
1 parent f214d08 commit e44f382

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

test/common.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ def also_with_wasmfs(f):
376376

377377
@wraps(f)
378378
def metafunc(self, wasmfs, *args, **kwargs):
379+
if DEBUG:
380+
print('parameterize:wasmfs=%d' % wasmfs)
379381
if wasmfs:
380382
self.set_setting('WASMFS')
381383
self.emcc_args.append('-DWASMFS')
@@ -393,6 +395,8 @@ def also_with_noderawfs(func):
393395

394396
@wraps(func)
395397
def metafunc(self, rawfs, *args, **kwargs):
398+
if DEBUG:
399+
print('parameterize:rawfs=%d' % rawfs)
396400
if rawfs:
397401
self.require_node()
398402
self.emcc_args += ['-DNODERAWFS']
@@ -410,6 +414,8 @@ def also_with_env_modify(name_updates_mapping):
410414
def decorated(f):
411415
@wraps(f)
412416
def metafunc(self, updates, *args, **kwargs):
417+
if DEBUG:
418+
print('parameterize:env_modify=%s' % (updates))
413419
if updates:
414420
with env_modify(updates):
415421
return f(self, *args, **kwargs)
@@ -432,6 +438,8 @@ def also_with_minimal_runtime(f):
432438

433439
@wraps(f)
434440
def metafunc(self, with_minimal_runtime, *args, **kwargs):
441+
if DEBUG:
442+
print('parameterize:minimal_runtime=%s' % with_minimal_runtime)
435443
assert self.get_setting('MINIMAL_RUNTIME') is None
436444
if with_minimal_runtime:
437445
self.set_setting('MINIMAL_RUNTIME', 1)
@@ -447,6 +455,8 @@ def also_with_wasm_bigint(f):
447455

448456
@wraps(f)
449457
def metafunc(self, with_bigint, *args, **kwargs):
458+
if DEBUG:
459+
print('parameterize:bigint=%s' % with_bigint)
450460
if with_bigint:
451461
if self.is_wasm2js():
452462
self.skipTest('wasm2js does not support WASM_BIGINT')
@@ -469,6 +479,8 @@ def also_with_wasm64(f):
469479

470480
@wraps(f)
471481
def metafunc(self, with_wasm64, *args, **kwargs):
482+
if DEBUG:
483+
print('parameterize:wasm64=%s' % with_wasm64)
472484
if with_wasm64:
473485
self.require_wasm64()
474486
self.set_setting('MEMORY64')
@@ -488,6 +500,8 @@ def also_with_wasm2js(f):
488500
@wraps(f)
489501
def metafunc(self, with_wasm2js, *args, **kwargs):
490502
assert self.get_setting('WASM') is None
503+
if DEBUG:
504+
print('parameterize:wasm2js=%s' % with_wasm2js)
491505
if with_wasm2js:
492506
self.require_wasm2js()
493507
self.set_setting('WASM', 0)
@@ -522,6 +536,8 @@ def also_with_standalone_wasm(impure=False):
522536
def decorated(func):
523537
@wraps(func)
524538
def metafunc(self, standalone):
539+
if DEBUG:
540+
print('parameterize:standalone=%s' % standalone)
525541
if not standalone:
526542
func(self)
527543
else:
@@ -559,6 +575,8 @@ def with_all_eh_sjlj(f):
559575

560576
@wraps(f)
561577
def metafunc(self, mode, *args, **kwargs):
578+
if DEBUG:
579+
print('parameterize:eh_mode=%s' % mode)
562580
if mode == 'wasm' or mode == 'wasm_exnref':
563581
# Wasm EH is currently supported only in wasm backend and V8
564582
if self.is_wasm2js():
@@ -719,7 +737,7 @@ def parameterize(func, parameters):
719737
if prev:
720738
# If we're parameterizing 2nd time, construct a cartesian product for various combinations.
721739
func._parameterize = {
722-
'_'.join(filter(None, [k1, k2])): v1 + v2 for (k1, v1), (k2, v2) in itertools.product(prev.items(), parameters.items())
740+
'_'.join(filter(None, [k1, k2])): v2 + v1 for (k1, v1), (k2, v2) in itertools.product(prev.items(), parameters.items())
723741
}
724742
else:
725743
func._parameterize = parameters

test/test_browser.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from tools import shared
2828
from tools import ports
2929
from tools import utils
30-
from tools.shared import EMCC, WINDOWS, FILE_PACKAGER, PIPE
30+
from tools.shared import EMCC, WINDOWS, FILE_PACKAGER, PIPE, DEBUG
3131
from tools.utils import delete_dir
3232

3333

@@ -82,6 +82,8 @@ def also_with_wasmfs(f):
8282

8383
@wraps(f)
8484
def metafunc(self, wasmfs, *args, **kwargs):
85+
if DEBUG:
86+
print('parameterize:wasmfs=%d' % wasmfs)
8587
if wasmfs:
8688
self.set_setting('WASMFS')
8789
self.emcc_args = self.emcc_args.copy() + ['-DWASMFS']
@@ -100,6 +102,8 @@ def also_with_proxying(f):
100102

101103
@wraps(f)
102104
def metafunc(self, proxied, *args, **kwargs):
105+
if DEBUG:
106+
print('parameterize:proxied=%d' % proxied)
103107
self.proxied = proxied
104108
f(self, *args, **kwargs)
105109

@@ -901,7 +905,7 @@ def test_sdl_canvas_alpha(self):
901905
'': (False,),
902906
'delay': (True,)
903907
})
904-
def test_sdl_key(self, delay, async_, defines):
908+
def test_sdl_key(self, defines, async_, delay):
905909
if delay:
906910
settimeout_start = 'setTimeout(function() {'
907911
settimeout_end = '}, 1);'
@@ -1970,11 +1974,11 @@ def test_cubegeom_pre2(self):
19701974
def test_cubegeom_pre3(self):
19711975
self.reftest('third_party/cubegeom/cubegeom_pre3.c', 'third_party/cubegeom/cubegeom_pre2.png', args=['-sLEGACY_GL_EMULATION', '-lGL', '-lSDL'])
19721976

1977+
@also_with_proxying
19731978
@parameterized({
19741979
'': ([],),
19751980
'tracing': (['-sTRACE_WEBGL_CALLS'],),
19761981
})
1977-
@also_with_proxying
19781982
@requires_graphics_hardware
19791983
def test_cubegeom(self, args):
19801984
if self.proxied and args:
@@ -2725,11 +2729,11 @@ def test_wget_data(self):
27252729
create_file('test.txt', 'emscripten')
27262730
self.btest_exit('test_wget_data.c', args=['-O2', '-g2', '-sASYNCIFY'])
27272731

2732+
@also_with_wasm2js
27282733
@parameterized({
27292734
'': ([],),
27302735
'es6': (['-sEXPORT_ES6'],),
27312736
})
2732-
@also_with_wasm2js
27332737
def test_locate_file(self, args):
27342738
self.set_setting('EXIT_RUNTIME')
27352739
create_file('src.c', r'''
@@ -4106,11 +4110,11 @@ def test_utf8_textdecoder(self):
41064110
def test_utf16_textdecoder(self):
41074111
self.btest_exit('benchmark/benchmark_utf16.cpp', 0, args=['--embed-file', test_file('utf16_corpus.txt') + '@/utf16_corpus.txt', '-sEXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,lengthBytesUTF16'])
41084112

4113+
@also_with_threads
41094114
@parameterized({
41104115
'': ([],),
41114116
'closure': (['--closure=1'],),
41124117
})
4113-
@also_with_threads
41144118
def test_TextDecoder(self, args):
41154119
self.emcc_args += args
41164120

@@ -4338,7 +4342,7 @@ def test_webgl_resize_offscreencanvas_from_main_thread(self, args1, args2, args3
43384342
'enable': (1,),
43394343
'disable': (0,),
43404344
})
4341-
def test_webgl_simple_extensions(self, simple_enable_extensions, webgl_version):
4345+
def test_webgl_simple_extensions(self, webgl_version, simple_enable_extensions):
43424346
cmd = ['-DWEBGL_CONTEXT_VERSION=' + str(webgl_version),
43434347
'-DWEBGL_SIMPLE_ENABLE_EXTENSION=' + str(simple_enable_extensions),
43444348
'-sMAX_WEBGL_VERSION=2',
@@ -4393,12 +4397,12 @@ def test_fetch_to_memory(self):
43934397
self.btest_exit('fetch/test_fetch_to_memory.cpp',
43944398
args=['-sFETCH_DEBUG', '-sFETCH'] + arg)
43954399

4400+
@also_with_wasm2js
43964401
@parameterized({
43974402
'': ([],),
43984403
'pthread_exit': (['-DDO_PTHREAD_EXIT'],),
43994404
})
44004405
@no_firefox('https://github.com/emscripten-core/emscripten/issues/16868')
4401-
@also_with_wasm2js
44024406
def test_fetch_from_thread(self, args):
44034407
shutil.copy(test_file('gears.png'), '.')
44044408
self.btest_exit('fetch/test_fetch_from_thread.cpp',
@@ -4628,11 +4632,11 @@ def test_single_file_html(self):
46284632
self.assertNotExists('test.wasm')
46294633

46304634
# Tests that SINGLE_FILE works as intended in generated HTML with MINIMAL_RUNTIME
4635+
@also_with_wasm2js
46314636
@parameterized({
46324637
'': ([],),
46334638
'O3': (['-O3'],)
46344639
})
4635-
@also_with_wasm2js
46364640
def test_minimal_runtime_single_file_html(self, opts):
46374641
self.btest('single_file_static_initializer.cpp', '19', args=opts + ['-sMINIMAL_RUNTIME', '-sSINGLE_FILE'])
46384642
self.assertExists('test.html')

test/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,13 +4624,13 @@ def test_dylink_postsets_chunking(self):
46244624
int global_var = 12345;
46254625
''', expected=['12345\n'], force_c=True)
46264626

4627+
@with_dylink_reversed
46274628
@parameterized({
46284629
'libcxx': ('libc,libc++,libmalloc,libc++abi',),
46294630
'all': ('1',),
46304631
'missing': ('libc,libmalloc,libc++abi', False, False, False),
46314632
'missing_assertions': ('libc,libmalloc,libc++abi', False, False, True),
46324633
})
4633-
@with_dylink_reversed
46344634
def test_dylink_syslibs(self, syslibs, expect_pass=True, with_reversed=True, assertions=True):
46354635
# one module uses libcxx, need to force its inclusion when it isn't the main
46364636
if not with_reversed and self.dylink_reversed:
@@ -9377,11 +9377,11 @@ def test_pthread_dylink_main_module_1(self):
93779377
self.set_setting('MAIN_MODULE')
93789378
self.do_runf('hello_world.c')
93799379

9380+
@with_dylink_reversed
93809381
@parameterized({
93819382
'': ([],),
93829383
'pthreads': (['-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME', '-pthread', '-Wno-experimental'],)
93839384
})
9384-
@with_dylink_reversed
93859385
def test_Module_dynamicLibraries(self, args):
93869386
# test that Module.dynamicLibraries works with pthreads
93879387
self.emcc_args += args

test/test_other.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def test_export_es6_allows_export_in_post_js(self):
429429
# load a worker before startup to check ES6 modules there as well
430430
'pthreads': (['-pthread', '-sPTHREAD_POOL_SIZE=1'],),
431431
})
432-
def test_export_es6(self, args, package_json):
432+
def test_export_es6(self, package_json, args):
433433
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6',
434434
'-o', 'hello.mjs'] + args)
435435
# In ES6 mode we use MODULARIZE, so we must instantiate an instance of the
@@ -1646,12 +1646,12 @@ def test_export_all_and_exported_functions(self):
16461646
self.emcc('lib.c', ['-sEXPORTED_FUNCTIONS=_libfunc2', '-sEXPORT_ALL', '--pre-js', 'pre.js'], output_filename='a.out.js')
16471647
self.assertContained('libfunc\n', self.run_js('a.out.js'))
16481648

1649+
@also_with_wasmfs
1650+
@crossplatform
16491651
@parameterized({
16501652
'': ([],),
16511653
'closure': (['-O2', '--closure=1'],),
16521654
})
1653-
@also_with_wasmfs
1654-
@crossplatform
16551655
def test_stdin(self, args):
16561656
create_file('in.txt', 'abcdef\nghijkl\n')
16571657
self.set_setting('ENVIRONMENT', 'node,shell')
@@ -2642,7 +2642,7 @@ def test_undefined_exported_js_function(self, outfile):
26422642
'error': ['ERROR'],
26432643
'ignore': [None]
26442644
})
2645-
def test_undefined_symbols(self, action, args):
2645+
def test_undefined_symbols(self, args, action):
26462646
create_file('main.c', r'''
26472647
#include <stdio.h>
26482648
#include <SDL.h>
@@ -4900,12 +4900,12 @@ def add_on_abort_and_verify(extra=''):
49004900
os.remove('a.out.wasm') # trigger onAbort by intentionally causing startup to fail
49014901
add_on_abort_and_verify()
49024902

4903+
@also_with_wasm2js
49034904
@parameterized({
49044905
'': ([],),
49054906
'01': (['-O1', '-g2'],),
49064907
'O2': (['-O2', '-g2', '-flto'],),
49074908
})
4908-
@also_with_wasm2js
49094909
def test_no_exit_runtime(self, opts):
49104910
create_file('code.cpp', r'''
49114911
#include <stdio.h>
@@ -5193,7 +5193,7 @@ def test_warn_dylibs(self):
51935193
'wasm2js': [0],
51945194
'wasm2js_2': [2],
51955195
})
5196-
def test_symbol_map(self, wasm, opts):
5196+
def test_symbol_map(self, opts, wasm):
51975197
def get_symbols_lines(symbols_file):
51985198
self.assertTrue(os.path.isfile(symbols_file), "Symbols file %s isn't created" % symbols_file)
51995199
# check that the map is correct
@@ -8304,7 +8304,7 @@ def test(contents, expected, args=[], assert_returncode=0): # noqa
83048304
'': ([],),
83058305
'O2': (['-O2'],),
83068306
})
8307-
def test_warn_unexported_main(self, args, filename):
8307+
def test_warn_unexported_main(self, filename, args):
83088308
warning = 'emcc: warning: `main` is defined in the input files, but `_main` is not in `EXPORTED_FUNCTIONS`. Add it to this list if you want `main` to run. [-Wunused-main]'
83098309

83108310
proc = self.run_process([EMCC, test_file(filename), '-sEXPORTED_FUNCTIONS=[]'] + args, stderr=PIPE)
@@ -13064,10 +13064,10 @@ def test_check_undefined(self, flag):
1306413064
err = self.expect_fail([EMCC, flag, '-sERROR_ON_UNDEFINED_SYMBOLS', test_file('other/test_check_undefined.c')])
1306513065
self.assertContained('undefined symbol: foo', err)
1306613066

13067+
@also_with_wasm64
1306713068
@parameterized({
1306813069
'asyncify': (['-sASYNCIFY'],),
1306913070
})
13070-
@also_with_wasm64
1307113071
def test_missing_symbols_at_runtime(self, args):
1307213072
# We deliberately pick a symbol there that takes a pointer as an argument.
1307313073
# We had a regression where the pointer-handling wrapper function could

0 commit comments

Comments
 (0)