Skip to content

Commit 96ca5bf

Browse files
authored
Parameterize test_embind. NFC (#16505)
This makes the test easier to read and breaks it up into 3. Each of these 3 tests still take a long time.. but 1/3 less.
1 parent 04cb61b commit 96ca5bf

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

tests/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,14 @@ def env_modify(updates):
223223

224224
# Decorator version of env_modify
225225
def with_env_modify(updates):
226+
assert not callable(updates)
227+
226228
def decorated(f):
227-
def modified(self):
229+
def modified(self, *args, **kwargs):
228230
with env_modify(updates):
229-
return f(self)
231+
return f(self, *args, **kwargs)
230232
return modified
233+
231234
return decorated
232235

233236

tests/test_other.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,20 +2427,20 @@ def test_embind_closure_no_dynamic_execution(self):
24272427
self.assertContained('10\nok\n', self.run_js('a.out.js'))
24282428

24292429
@is_slow_test
2430+
@parameterized({
2431+
'': [[]],
2432+
'no_utf8': [['-sEMBIND_STD_STRING_IS_UTF8=0']],
2433+
'no_dynamic': [['-sDYNAMIC_EXECUTION=0']],
2434+
})
24302435
@with_env_modify({'EMCC_CLOSURE_ARGS': '--externs ' + shlex.quote(test_file('embind/underscore-externs.js'))})
2431-
def test_embind(self):
2436+
def test_embind(self, extra_args):
24322437
test_cases = [
2433-
(['-lembind']),
2434-
(['-lembind', '-O1']),
2435-
(['-lembind', '-O2']),
2436-
(['-lembind', '-O2', '-sALLOW_MEMORY_GROWTH', test_file('embind/isMemoryGrowthEnabled=true.cpp')]),
2438+
(['-lembind']),
2439+
(['-lembind', '-O1']),
2440+
(['-lembind', '-O2']),
2441+
(['-lembind', '-O2', '-sALLOW_MEMORY_GROWTH', test_file('embind/isMemoryGrowthEnabled=true.cpp')]),
24372442
]
2438-
without_utf8_args = ['-sEMBIND_STD_STRING_IS_UTF8=0']
2439-
test_cases_without_utf8 = []
2440-
for args in test_cases:
2441-
test_cases_without_utf8.append((args + without_utf8_args))
2442-
test_cases += test_cases_without_utf8
2443-
test_cases.extend([(args[:] + ['-sDYNAMIC_EXECUTION=0']) for args in test_cases])
2443+
test_cases = [t + extra_args for t in test_cases]
24442444
# closure compiler doesn't work with DYNAMIC_EXECUTION=0
24452445
test_cases.append((['-lembind', '-O2', '--closure=1']))
24462446
for args in test_cases:

0 commit comments

Comments
 (0)