diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-04-05 19:03:06 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-04-28 17:54:02 +0200 |
commit | 4a1f1977435c7153d97652984aa783c2cbd1e803 (patch) | |
tree | ef8a03bf3aad82ee619cb4287570ba3c47440139 /run_project_tests.py | |
parent | 20bacf82eea4bd0d3732c398298c27e0d82a526d (diff) | |
download | meson-4a1f1977435c7153d97652984aa783c2cbd1e803.zip meson-4a1f1977435c7153d97652984aa783c2cbd1e803.tar.gz meson-4a1f1977435c7153d97652984aa783c2cbd1e803.tar.bz2 |
tests: Add support for specifying tool requirements
Adds the `tools` section to `tests.json` to specify requirements
for the tools in the environment. All tests that fail at least
one tool requirements check are skipped.
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-x | run_project_tests.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/run_project_tests.py b/run_project_tests.py index 875a522..cc8e333 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -190,7 +190,7 @@ class TestDef: self.skip = skip self.env = os.environ.copy() self.installed_files = [] # type: T.List[InstalledFile] - self.do_not_set_opts = [] # type: T.List[str] + self.do_not_set_opts = [] # type: T.List[str] def __repr__(self) -> str: return '<{}: {:<48} [{}: {}] -- {}>'.format(type(self).__name__, str(self.path), self.name, self.args, self.skip) @@ -233,6 +233,7 @@ no_meson_log_msg = 'No meson-log.txt found.' system_compiler = None compiler_id_map = {} # type: T.Dict[str, str] +tool_vers_map = {} # type: T.Dict[str, str] class StopException(Exception): def __init__(self): @@ -568,6 +569,15 @@ def gather_tests(testdir: Path) -> T.List[TestDef]: # Handle the do_not_set_opts list do_not_set_opts = test_def.get('do_not_set_opts', []) # type: T.List[str] + # Skip tests if the tool requirements are not met + if 'tools' in test_def: + assert isinstance(test_def['tools'], dict) + for tool, vers_req in test_def['tools'].items(): + if tool not in tool_vers_map: + t.skip = True + elif not mesonlib.version_compare(tool_vers_map[tool], vers_req): + t.skip = True + # Skip the matrix code and just update the existing test if 'matrix' not in test_def: t.env.update(env) @@ -639,7 +649,7 @@ def gather_tests(testdir: Path) -> T.List[TestDef]: name = ' '.join([x[0] for x in i if x[0] is not None]) opts = ['-D' + x[0] for x in i if x[0] is not None] skip = any([x[1] for x in i]) - test = TestDef(t.path, name, opts, skip) + test = TestDef(t.path, name, opts, skip or t.skip) test.env.update(env) test.installed_files = installed test.do_not_set_opts = do_not_set_opts @@ -1123,6 +1133,7 @@ def print_tool_versions(): i = i.strip('\n\r\t ') m = t['regex'].match(i) if m is not None: + tool_vers_map[t['tool']] = m.group(t['match_group']) return '{} ({})'.format(exe, m.group(t['match_group'])) return '{} (unknown)'.format(exe) |