Skip to content

Commit

Permalink
[test] Enable EMTEST_SKIP_CCACHE to skip ccache tests. NFC
Browse files Browse the repository at this point in the history
We will likely use this on the emscripten-releases.
  • Loading branch information
sbc100 committed Oct 15, 2024
1 parent daf541c commit 36c12a8
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,43 +142,39 @@ def metafunc(self, backend, *args, **kwargs):
return metafunc


def requires_ninja(func):
assert callable(func)
def requires_tool(tool):
assert not callable(tool)

@wraps(func)
def decorated(self, *args, **kwargs):
if not shutil.which('ninja'):
self.fail('test requires ninja to be installed (available in PATH)')
return func(self, *args, **kwargs)
def decorate(func):
assert callable(func)

return decorated
@wraps(func)
def decorated(self, *args, **kwargs):
if not shutil.which(tool):
if f'EMTEST_SKIP_{tool.upper()}' in os.environ:
self.skipTest(f'test requires ccache and EMTEST_SKIP_{tool.upper()} is set')
else:
self.fail(f'{tool} required to run this test. Use EMTEST_SKIP_{tool.upper()} to skip')
return func(self, *args, **kwargs)

return decorated

def requires_ccache(func):
assert callable(func)
return decorate

@wraps(func)
def decorated(self, *args, **kwargs):
if not shutil.which('ccache'):
self.fail('test requires ccache to be installed (available in PATH)')
return func(self, *args, **kwargs)

return decorated
def requires_ninja(func):
assert callable(func)
return requires_tool('ninja')(func)


def requires_scons(func):
def requires_ccache(func):
assert callable(func)
return requires_tool('ccache')(func)

@wraps(func)
def decorated(self, *args, **kwargs):
if not shutil.which('scons'):
if 'EMTEST_SKIP_SCONS' in os.environ:
self.skipTest('test requires scons and EMTEST_SKIP_SCONS is set')
else:
self.fail('scons required to run this test. Use EMTEST_SKIP_SCONS to skip')
return func(self, *args, **kwargs)

return decorated
def requires_scons(func):
assert callable(func)
return requires_tool('scons')(func)


def requires_pkg_config(func):
Expand Down

0 comments on commit 36c12a8

Please sign in to comment.