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 "orc:test_accsadubl (default)".

Fix tests having no suite in the case `suite: []` is passed. Empty list
is now converted to `['']` which was the default value of that kwarg.
pull/12916/head
Xavier Claessens 1 year ago
parent fb72a8ecdb
commit b63917d54d
  1. 10
      mesonbuild/interpreter/type_checking.py
  2. 18
      mesonbuild/mtest.py

@ -484,6 +484,14 @@ 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, it will be set to project name.
if not suite:
return ['']
return suite
TEST_KWS: T.List[KwargInfo] = [
KwargInfo('args', ContainerTypeInfo(list, (str, File, BuildTarget, CustomTarget, CustomTargetIndex)),
listify=True, default=[]),
@ -499,7 +507,7 @@ TEST_KWS: 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'),
]

@ -1980,14 +1980,18 @@ class TestHarness:
return wrap
def get_pretty_suite(self, test: TestSerialisation) -> str:
if len(self.suites) > 1 and test.suite:
rv = TestHarness.split_suite_string(test.suite[0])[0]
s = "+".join(TestHarness.split_suite_string(s)[1] for s in test.suite)
assert test.suite, 'Interpreter should ensure there is always at least one suite'
prj = TestHarness.split_suite_string(test.suite[0])[0]
suites: T.List[str] = []
for i in test.suite:
s = TestHarness.split_suite_string(i)[1]
if s:
rv += ":"
return rv + s + " / " + test.name
else:
return test.name
suites.append(s)
name = f'{prj}:{test.name}'
if suites:
s = ', '.join(suites)
name += f' ({s})'
return name
def run_tests(self, runners: T.List[SingleTestRunner]) -> None:
try:

Loading…
Cancel
Save