From 4640f13faa899a2de58ef4d835605f53b46550f3 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 5 Apr 2020 18:52:28 +0200 Subject: docs: Fix Contributing.md --- docs/markdown/Contributing.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/markdown') diff --git a/docs/markdown/Contributing.md b/docs/markdown/Contributing.md index 53329389b..554c3f5cc 100644 --- a/docs/markdown/Contributing.md +++ b/docs/markdown/Contributing.md @@ -174,7 +174,7 @@ contents of an additional file into the CI log on failure. Projects needed by unit tests are in the `test cases/unit` subdirectory. They are not run as part of `./run_project_tests.py`. -#### Configuring project tests +### Configuring project tests The (optional) `test.json` file, in the root of a test case, is used for configuring the test. All of the following root entries in the `test.json` @@ -213,13 +213,13 @@ Exanple `test.json`: } ``` -##### env +#### env The `env` key contains a dictionary which specifies additional environment variables to be set during the configure step of the test. `@ROOT@` is replaced with the absolute path of the source directory. -##### installed +#### installed The `installed` dict contains a list of dicts, describing which files are expected to be installed. Each dict contains the following keys: @@ -277,7 +277,7 @@ the platform matches. The following values for `platform` are currently supporte | `cygwin` | Matches when the platform is cygwin | | `!cygwin` | Not `cygwin` | -##### matrix +#### matrix The `matrix` section can be used to define a test matrix to run project tests with different meson options. @@ -318,7 +318,7 @@ The above example will produce the following matrix entries: - `opt1=qwert` - `opt1=qwert opt2=true` -##### do_not_set_opts +#### do_not_set_opts Currently supported values are: - `prefix` -- cgit v1.2.3 From 4a1f1977435c7153d97652984aa783c2cbd1e803 Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 5 Apr 2020 19:03:06 +0200 Subject: 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. --- docs/markdown/Contributing.md | 10 ++++++++++ run_project_tests.py | 15 +++++++++++++-- test cases/cmake/2 advanced/test.json | 5 ++++- test cases/cmake/3 advanced no dep/test.json | 5 ++++- 4 files changed, 31 insertions(+), 4 deletions(-) (limited to 'docs/markdown') diff --git a/docs/markdown/Contributing.md b/docs/markdown/Contributing.md index 554c3f5cc..8a24e0bad 100644 --- a/docs/markdown/Contributing.md +++ b/docs/markdown/Contributing.md @@ -209,6 +209,9 @@ Exanple `test.json`: { "opt1": "qwert", "opt2": "false" }, { "opt1": "bad" } ] + }, + "tools": { + "cmake": ">=3.11" } } ``` @@ -324,6 +327,13 @@ Currently supported values are: - `prefix` - `libdir` +#### tools + +This section specifies a list of tool requirements in a simple key-value format. +If a tool is specified, it has to be present in the environment, and the version +requirement must be fulfilled match. Otherwise, the entire test is skipped +(including every element in the test matrix). + ### Skipping integration tests Meson uses several continuous integration testing systems that have slightly diff --git a/run_project_tests.py b/run_project_tests.py index 875a5223e..cc8e33356 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) diff --git a/test cases/cmake/2 advanced/test.json b/test cases/cmake/2 advanced/test.json index 11aad947d..e12f530b8 100644 --- a/test cases/cmake/2 advanced/test.json +++ b/test cases/cmake/2 advanced/test.json @@ -4,5 +4,8 @@ {"type": "implib", "platform": "cygwin", "file": "usr/lib/libcm_cmModLib"}, {"type": "implib", "platform": "!cygwin", "file": "usr/bin/libcm_cmModLib"}, {"type": "exe", "file": "usr/bin/cm_testEXE"} - ] + ], + "tools": { + "cmake": ">=3.11" + } } diff --git a/test cases/cmake/3 advanced no dep/test.json b/test cases/cmake/3 advanced no dep/test.json index 24c89c4ed..98a1719cc 100644 --- a/test cases/cmake/3 advanced no dep/test.json +++ b/test cases/cmake/3 advanced no dep/test.json @@ -8,5 +8,8 @@ {"type": "exe", "file": "usr/bin/cm_testEXE"}, {"type": "pdb", "file": "usr/bin/cm_testEXE2"}, {"type": "exe", "file": "usr/bin/cm_testEXE2"} - ] + ], + "tools": { + "cmake": ">=3.11" + } } -- cgit v1.2.3