Skip to content

Commit

Permalink
[test] Rename EMTEST_SKIP_CARGO -> EMTEST_SKIP_RUST. NFC (#22982)
Browse files Browse the repository at this point in the history
See #22964
  • Loading branch information
sbc100 authored Nov 21, 2024
1 parent 319b423 commit bd2de9c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,23 @@ def metafunc(self, backend, *args, **kwargs):
return metafunc


def requires_tool(tool):
def requires_tool(tool, env_name=None):
assert not callable(tool)

def decorate(func):
assert callable(func)

@wraps(func)
def decorated(self, *args, **kwargs):
if env_name:
env_var = f'EMTEST_SKIP_{env_name}'
else:
env_var = f'EMTEST_SKIP_{tool.upper()}'
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')
if env_var in os.environ:
self.skipTest(f'test requires ccache and {env_var} is set')
else:
self.fail(f'{tool} required to run this test. Use EMTEST_SKIP_{tool.upper()} to skip')
self.fail(f'{tool} required to run this test. Use {env_var} to skip')
return func(self, *args, **kwargs)

return decorated
Expand All @@ -174,7 +178,7 @@ def requires_scons(func):

def requires_rust(func):
assert callable(func)
return requires_tool('cargo')(func)
return requires_tool('cargo', 'RUST')(func)


def requires_pkg_config(func):
Expand Down

0 comments on commit bd2de9c

Please sign in to comment.