Skip to content

Commit ea15105

Browse files
authored
[test] Update also_with_thread decorator to use parameterization. NFC (#22019)
1 parent 0c1d954 commit ea15105

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

test/test_browser.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,15 @@ def decorated(self, *args, **kwargs):
176176
def also_with_threads(f):
177177
assert callable(f)
178178

179-
@wraps(f)
180-
def decorated(self, *args, **kwargs):
181-
f(self, *args, **kwargs)
182-
print('(threads)')
183-
self.emcc_args += ['-pthread']
179+
def metafunc(self, threads, *args, **kwargs):
180+
if threads:
181+
self.emcc_args += ['-pthread']
184182
f(self, *args, **kwargs)
185183

186-
return decorated
184+
metafunc._parameterize = {'': (False,),
185+
'threads': (True,)}
186+
187+
return metafunc
187188

188189

189190
def skipExecIf(cond, message):
@@ -1605,25 +1606,20 @@ def test_glfw_minimal(self):
16051606
def test_glfw_time(self):
16061607
self.btest_exit('test_glfw_time.c', args=['-sUSE_GLFW=3', '-lglfw', '-lGL'])
16071608

1608-
def _test_egl_base(self, *args):
1609-
self.btest_exit('test_egl.c', args=['-O2', '-lEGL', '-lGL', '-sGL_ENABLE_GET_PROC_ADDRESS'] + list(args))
1610-
1611-
@requires_graphics_hardware
1612-
def test_egl(self):
1613-
self._test_egl_base()
1614-
1609+
@parameterized({
1610+
'': ([],),
1611+
'proxy_to_pthread': (['-pthread', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER'],),
1612+
})
16151613
@requires_graphics_hardware
1616-
def test_egl_with_proxy_to_pthread(self):
1617-
self._test_egl_base('-pthread', '-sPROXY_TO_PTHREAD', '-sOFFSCREEN_FRAMEBUFFER')
1618-
1619-
def _test_egl_width_height_base(self, *args):
1620-
self.btest_exit('test_egl_width_height.c', args=['-O2', '-lEGL', '-lGL'] + list(args))
1621-
1622-
def test_egl_width_height(self):
1623-
self._test_egl_width_height_base()
1614+
def test_egl(self, args):
1615+
self.btest_exit('test_egl.c', args=['-O2', '-lEGL', '-lGL', '-sGL_ENABLE_GET_PROC_ADDRESS'] + args)
16241616

1625-
def test_egl_width_height_with_proxy_to_pthread(self):
1626-
self._test_egl_width_height_base('-pthread', '-sPROXY_TO_PTHREAD')
1617+
@parameterized({
1618+
'': ([],),
1619+
'proxy_to_pthread': (['-pthread', '-sPROXY_TO_PTHREAD'],),
1620+
})
1621+
def test_egl_width_height(self, args):
1622+
self.btest_exit('test_egl_width_height.c', args=['-O2', '-lEGL', '-lGL'] + args)
16271623

16281624
@requires_graphics_hardware
16291625
def test_egl_createcontext_error(self):

0 commit comments

Comments
 (0)