diff options
| -rw-r--r-- | mesonbuild/interpreter/type_checking.py | 8 | ||||
| -rw-r--r-- | mesonbuild/mtest.py | 39 | ||||
| -rw-r--r-- | unittests/allplatformstests.py | 10 |
3 files changed, 28 insertions, 29 deletions
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 2bf356058..3178cc607 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -490,6 +490,12 @@ VARIABLES_KW: KwargInfo[T.Dict[str, str]] = KwargInfo( PRESERVE_PATH_KW: KwargInfo[bool] = KwargInfo('preserve_path', bool, default=False, since='0.63.0') +def suite_convertor(suite: T.List[str]) -> T.List[str]: + # Ensure we always have at least one suite. + if not suite: + return [''] + return suite + TEST_KWS_NO_ARGS: T.List[KwargInfo] = [ KwargInfo('should_fail', bool, default=False), KwargInfo('timeout', int, default=30), @@ -503,7 +509,7 @@ TEST_KWS_NO_ARGS: T.List[KwargInfo] = [ # TODO: env needs reworks of the way the environment variable holder itself works probably ENV_KW, DEPENDS_KW.evolve(since='0.46.0'), - KwargInfo('suite', ContainerTypeInfo(list, str), listify=True, default=['']), # yes, a list of empty string + KwargInfo('suite', ContainerTypeInfo(list, str), listify=True, default=[], convertor=suite_convertor), KwargInfo('verbose', bool, default=False, since='0.62.0'), ] diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index c0a22a248..337b70747 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1939,29 +1939,22 @@ class TestHarness: 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 handle 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: - continue - return True + # The SUITE can be passed as + # - `name` - We select tests belonging to (sub)project OR suite + # with the given name. + # - `:suite_name` - We select tests belonging to any (sub)projects + # and in suite_name. + # - `project_name:suite_name` - We select tests belonging + # to project_name and in suite_name. + if not st_match: + if prj_match in {prj, st}: + return True + elif not prj_match: + if st == st_match: + return True + else: + if prj == prj_match and st == st_match: + return True return False def test_suitable(self, test: TestSerialisation) -> bool: diff --git a/unittests/allplatformstests.py b/unittests/allplatformstests.py index 691780195..023b8c2ad 100644 --- a/unittests/allplatformstests.py +++ b/unittests/allplatformstests.py @@ -911,11 +911,11 @@ class AllPlatformTests(BasePlatformTests): self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'mainprj']) self.assertFailedTestCount(0, self.mtest_command + ['--suite', 'subprjsucc']) - self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjfail']) + self.assertFailedTestCount(2, self.mtest_command + ['--suite', 'subprjfail']) self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjmix']) self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'mainprj']) self.assertFailedTestCount(4, self.mtest_command + ['--no-suite', 'subprjsucc']) - self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjfail']) + self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjfail']) self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjmix']) self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'mainprj:fail']) @@ -938,9 +938,9 @@ class AllPlatformTests(BasePlatformTests): self.assertFailedTestCount(3, self.mtest_command + ['--no-suite', 'subprjmix:fail']) self.assertFailedTestCount(4, self.mtest_command + ['--no-suite', 'subprjmix:success']) - self.assertFailedTestCount(2, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix:fail']) - self.assertFailedTestCount(3, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj']) - self.assertFailedTestCount(2, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj', '--no-suite', 'subprjmix:fail']) + self.assertFailedTestCount(3, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix:fail']) + self.assertFailedTestCount(4, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj']) + self.assertFailedTestCount(3, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj', '--no-suite', 'subprjmix:fail']) self.assertFailedTestCount(1, self.mtest_command + ['--suite', 'subprjfail', '--suite', 'subprjmix', '--suite', 'mainprj', '--no-suite', 'subprjmix:fail', 'mainprj-failing_test']) self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjfail:fail', '--no-suite', 'subprjmix:fail']) |
