Skip to content

Commit 1d12e52

Browse files
committed
mtest: Display test name in format expected by "meson test" argument
This makes easier to run a single test after running them all. For example the test "test_accsadubl" in the suite "default" of project "orc" used to be displayed "orc:default / test_accsadubl". To run that test specifically the command line is `meson test -C builddir orc:test_accsadubl --suite default`. To make this more consistent the test is now displayed as "default - orc:test_accsadubl".
1 parent 59a46da commit 1d12e52

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎mesonbuild/mtest.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,14 +2073,18 @@ def get_wrapper(options: argparse.Namespace) -> T.List[str]:
20732073
return wrap
20742074

20752075
def get_pretty_suite(self, test: TestSerialisation) -> str:
2076-
if len(self.suites) > 1 and test.suite:
2077-
rv = TestHarness.split_suite_string(test.suite[0])[0]
2078-
s = "+".join(TestHarness.split_suite_string(s)[1] for s in test.suite)
2076+
assert test.suite, 'Interpreter should ensure there is always at least one suite'
2077+
prj = TestHarness.split_suite_string(test.suite[0])[0]
2078+
suites: T.List[str] = []
2079+
for i in test.suite:
2080+
s = TestHarness.split_suite_string(i)[1]
20792081
if s:
2080-
rv += ":"
2081-
return rv + s + " / " + test.name
2082-
else:
2083-
return test.name
2082+
suites.append(s)
2083+
name = f'{prj}:{test.name}'
2084+
if suites:
2085+
s = '+'.join(suites)
2086+
name = f'{s} - {name}'
2087+
return name
20842088

20852089
def run_tests(self, runners: T.List[SingleTestRunner]) -> None:
20862090
try:

‎unittests/allplatformstests.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ def test_mtest_reconfigure(self):
954954
self.utime(os.path.join(testdir, 'meson.build'))
955955
o = self._run(self.mtest_command + ['--list'])
956956
self.assertIn('Regenerating build files', o)
957-
self.assertIn('test_features / xfail', o)
957+
self.assertIn('test_features:xfail', o)
958958
o = self._run(self.mtest_command + ['--list'])
959959
self.assertNotIn('Regenerating build files', o)
960960
# no real targets should have been built
@@ -5437,7 +5437,7 @@ def test_slice(self):
54375437
'10/10': [10],
54385438
}.items():
54395439
output = self._run(self.mtest_command + ['--slice=' + arg])
5440-
tests = sorted([ int(x) for x in re.findall(r'\n[ 0-9]+/[0-9]+ test-([0-9]*)', output) ])
5440+
tests = sorted([ int(x) for x in re.findall(r'\n[ 0-9]+/[0-9]+ test_slice:test-([0-9]*)', output) ])
54415441
self.assertEqual(tests, expectation)
54425442

54435443
for arg, expectation in {'': 'error: argument --slice: value does not conform to format \'SLICE/NUM_SLICES\'',

0 commit comments

Comments
 (0)