aboutsummaryrefslogtreecommitdiff
path: root/run_project_tests.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-20 00:55:56 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-04-03 16:06:33 -0400
commit105bbaabdda4656194e97729f67bba9c0f6c8ae1 (patch)
tree0546706d374c1bec6b9bf9448202290c9eb9019f /run_project_tests.py
parentce7a67e511467f72c52c950fb0e0c48a69054974 (diff)
downloadmeson-105bbaabdda4656194e97729f67bba9c0f6c8ae1.zip
meson-105bbaabdda4656194e97729f67bba9c0f6c8ae1.tar.gz
meson-105bbaabdda4656194e97729f67bba9c0f6c8ae1.tar.bz2
project tests: log the reason why a test is skipped
We expose a reason after the string 'MESON_SKIP_TEST', but it is actually ignored when running the test, so it is only useful as documentation and really might as well be a comment. Make it even more useful by actually printing that string after the '[SKIPPED]' message. Also, sometimes a test can be skipped for multiple reasons, and it would be useful to know which one occurred.
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-xrun_project_tests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index ed09870..893107a 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -1173,6 +1173,12 @@ class LogRunFuture:
RunFutureUnion = T.Union[TestRunFuture, LogRunFuture]
+def test_emits_skip_msg(line: str) -> bool:
+ for prefix in {'Problem encountered', 'Assert failed', 'Failed to configure the CMake subproject'}:
+ if f'{prefix}: MESON_SKIP_TEST' in line:
+ return True
+ return False
+
def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
log_name_base: str,
failfast: bool,
@@ -1281,10 +1287,19 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
if result is None:
# skipped due to skipped category skip or 'tools:' or 'skip_on_env:'
is_skipped = True
+ skip_reason = 'not run because preconditions were not met'
skip_as_expected = True
else:
# skipped due to test outputting 'MESON_SKIP_TEST'
- is_skipped = 'MESON_SKIP_TEST' in result.stdo
+ for l in result.stdo.splitlines():
+ if test_emits_skip_msg(l):
+ is_skipped = True
+ offset = l.index('MESON_SKIP_TEST') + 16
+ skip_reason = l[offset:].strip()
+ break
+ else:
+ is_skipped = False
+ skip_reason = ''
if not skip_dont_care(t):
skip_as_expected = (is_skipped == t.skip_expected)
else:
@@ -1295,6 +1310,7 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
if is_skipped and skip_as_expected:
f.update_log(TestStatus.SKIP)
+ safe_print(bold('Reason:'), skip_reason)
current_test = ET.SubElement(current_suite, 'testcase', {'name': testname, 'classname': t.category})
ET.SubElement(current_test, 'skipped', {})
continue