diff --git a/test/common.py b/test/common.py index 78bbd5d591ab9..19d0245dbee4a 100644 --- a/test/common.py +++ b/test/common.py @@ -863,6 +863,7 @@ def setUp(self): super().setUp() self.js_engines = config.JS_ENGINES.copy() self.settings_mods = {} + self.skipExec = None self.emcc_args = ['-Wclosure', '-Werror', '-Wno-limited-postlink-optimizations'] # TODO(https://github.com/emscripten-core/emscripten/issues/11121) # For historical reasons emcc compiles and links as C++ by default. @@ -1967,6 +1968,8 @@ def assert_out_queue_empty(self, who): def run_browser(self, html_file, expected=None, message=None, timeout=None, extra_tries=1): if not has_browser(): return + if self.skipExec: + self.skipTest('skipping test execution: ' + self.skipExec) if BrowserCore.unresponsive_tests >= BrowserCore.MAX_UNRESPONSIVE_TESTS: self.skipTest('too many unresponsive tests, skipping remaining tests') self.assert_out_queue_empty('previous test') diff --git a/test/test_browser.py b/test/test_browser.py index 0c7048c7c2eb9..8520f08aa09b6 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -187,9 +187,24 @@ def decorated(self, *args, **kwargs): return decorated -requires_graphics_hardware = unittest.skipIf(os.getenv('EMTEST_LACKS_GRAPHICS_HARDWARE'), "This test requires graphics hardware") -requires_sound_hardware = unittest.skipIf(os.getenv('EMTEST_LACKS_SOUND_HARDWARE'), "This test requires sound hardware") -requires_offscreen_canvas = unittest.skipIf(os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'), "This test requires a browser with OffscreenCanvas") +def skipExecIf(cond, message): + def decorator(f): + assert callable(f) + + @wraps(f) + def decorated(self, *args, **kwargs): + if cond: + self.skipExec = message + f(self, *args, **kwargs) + + return decorated + + return decorator + + +requires_graphics_hardware = skipExecIf(os.getenv('EMTEST_LACKS_GRAPHICS_HARDWARE'), 'This test requires graphics hardware') +requires_sound_hardware = skipExecIf(os.getenv('EMTEST_LACKS_SOUND_HARDWARE'), 'This test requires sound hardware') +requires_offscreen_canvas = skipExecIf(os.getenv('EMTEST_LACKS_OFFSCREEN_CANVAS'), 'This test requires a browser with OffscreenCanvas') class browser(BrowserCore):