aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mtest.py
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-02-02 09:27:16 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2021-02-02 11:23:33 +0100
commitc7c2bc8db111a5be277aeb14aecfe0d28ab286a9 (patch)
tree127faceadf8c8299c65e0c8fd41b5991e5a76cee /mesonbuild/mtest.py
parente7b587c81fdea066d258517e9c4862e57cb22e02 (diff)
downloadmeson-c7c2bc8db111a5be277aeb14aecfe0d28ab286a9.zip
meson-c7c2bc8db111a5be277aeb14aecfe0d28ab286a9.tar.gz
meson-c7c2bc8db111a5be277aeb14aecfe0d28ab286a9.tar.bz2
interpreter, mtest: introduce add_test_setup(exclude_suites: ...)
This new keyword argument makes it possible to run specific test setups only on a subset of the tests. For example, to mark some tests as slow and avoid running them by default: add_test_setup('quick', exclude_suites: ['slow'], is_default: true) add_test_setup('slow') It will then be possible to run the slow tests with either `meson test --setup slow` or `meson test --suite slow`.
Diffstat (limited to 'mesonbuild/mtest.py')
-rw-r--r--mesonbuild/mtest.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index d212cf0..79bb075 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -1654,9 +1654,20 @@ class TestHarness:
return False
def test_suitable(self, test: TestSerialisation) -> bool:
- return ((not self.options.include_suites or
- TestHarness.test_in_suites(test, self.options.include_suites)) and not
- TestHarness.test_in_suites(test, self.options.exclude_suites))
+ if TestHarness.test_in_suites(test, self.options.exclude_suites):
+ return False
+
+ if self.options.include_suites:
+ # Both force inclusion (overriding add_test_setup) and exclude
+ # everything else
+ return TestHarness.test_in_suites(test, self.options.include_suites)
+
+ if self.options.setup:
+ setup = self.get_test_setup(test)
+ if TestHarness.test_in_suites(test, setup.exclude_suites):
+ return False
+
+ return True
def tests_from_args(self, tests: T.List[TestSerialisation]) -> T.Generator[TestSerialisation, None, None]:
'''
@@ -1685,14 +1696,7 @@ class TestHarness:
print('No tests defined.')
return []
- if self.options.include_suites or self.options.exclude_suites:
- tests = []
- for tst in self.tests:
- if self.test_suitable(tst):
- tests.append(tst)
- else:
- tests = self.tests
-
+ tests = [t for t in self.tests if self.test_suitable(t)]
if self.options.args:
tests = list(self.tests_from_args(tests))