From 717f7db67e27fedc4a3eb68bf2b46bf4384997c6 Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Sat, 14 Apr 2018 21:17:02 +0200 Subject: improve suite of meson test (#3369) --- docs/markdown/Reference-manual.md | 6 ++++++ docs/markdown/Unit-tests.md | 8 ++++++++ mesonbuild/mtest.py | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 0d3d1aa..da4c92b 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -1243,6 +1243,12 @@ Keyword arguments are the following: - `should_fail` when true the test is considered passed if the executable returns a non-zero return value (i.e. reports an error) +- `suite` `'label'` (or list of labels `['label1', 'label2']`) + attached to this test. The suite name is qualified by a (sub)project + name resulting in `(sub)project_name:label`. In the case of a list + of strings, the suite names will be `(sub)project_name:label1`, + `(sub)project_name:label2`, etc. + - `timeout` the amount of seconds the test is allowed to run, a test that exceeds its time limit is always considered failed, defaults to 30 seconds diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md index 53ce9ec..e5e4107 100644 --- a/docs/markdown/Unit-tests.md +++ b/docs/markdown/Unit-tests.md @@ -71,6 +71,14 @@ You can also run only a single test by giving its name: $ meson test testname ``` +Tests belonging to a suite `suite` can be run as follows + +```console +$ meson test --suite (sub)project_name:suite +``` + +Since version *0.46*, `(sub)project_name` can be omitted if it is the top-level project. + Sometimes you need to run the tests multiple times, which is done like this: ```console diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 91567f2..110a94e 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -476,6 +476,25 @@ TIMEOUT: %4d (prj_match, st_match) = TestHarness.split_suite_string(suite) for prjst in test.suite: (prj, st) = TestHarness.split_suite_string(prjst) + + # the SUITE can be passed as + # suite_name + # or + # project_name:suite_name + # so we need to select only the test belonging to project_name + + # this if hanlde the first case (i.e., SUITE == suite_name) + + # in this way we can run tests belonging to different + # (sub)projects which share the same suite_name + if not st_match and st == prj_match: + return True + + # these two conditions are needed to handle the second option + # i.e., SUITE == project_name:suite_name + + # in this way we select the only the tests of + # project_name with suite_name if prj_match and prj != prj_match: continue if st_match and st != st_match: -- cgit v1.1