commit 6f884204aa2058cc1b8921dedd34628ba9e978ed
parent 1113235d052edf6687d12de90956a6bfd5a50b4e
Author: Florian Quèze <florian@queze.net>
Date: Mon, 13 Oct 2025 20:54:14 +0000
Bug 1994065 - log only the skip-if condition that was used to decide to skip the test when logging test_end with status=SKIP, r=jmaher.
Differential Revision: https://phabricator.services.mozilla.com/D268451
Diffstat:
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/testing/mozbase/manifestparser/manifestparser/filters.py b/testing/mozbase/manifestparser/manifestparser/filters.py
@@ -21,9 +21,11 @@ from .util import normsep
def _match(exprs, strict, **values):
- if any(parse(e, strict=strict, **values) for e in exprs.splitlines() if e):
- return True
- return False
+ """Return the first matching expression, or None if no match."""
+ for e in exprs.splitlines():
+ if e and parse(e, strict=strict, **values):
+ return e
+ return None
def skip_if(tests, values, strict=False):
@@ -33,8 +35,10 @@ def skip_if(tests, values, strict=False):
"""
tag = "skip-if"
for test in tests:
- if tag in test and _match(test[tag], strict, **values):
- test.setdefault("disabled", f"{tag}: {test[tag]}")
+ if tag in test:
+ matching_expr = _match(test[tag], strict, **values)
+ if matching_expr:
+ test.setdefault("disabled", f"{tag}: {matching_expr}")
yield test
@@ -46,11 +50,11 @@ def run_if(tests, values, strict=False):
tag = "run-if"
for test in tests:
if tag in test:
- # logical &&, not ||
- if not all(
- parse(e, strict=strict, **values) for e in test[tag].splitlines() if e
- ):
- test.setdefault("disabled", f"{tag}: {test[tag]}")
+ # logical &&, not || - find first condition that didn't match
+ for e in test[tag].splitlines():
+ if e and not parse(e, strict=strict, **values):
+ test.setdefault("disabled", f"{tag}: {e}")
+ break
yield test
diff --git a/testing/mozbase/manifestparser/tests/test_filters.py b/testing/mozbase/manifestparser/tests/test_filters.py
@@ -160,7 +160,7 @@ def tests(create_tests):
return create_tests(
"test0",
("test1", {"skip-if": "foo == 'bar'\nintermittent&&!debug"}),
- ("test2", {"run-if": "foo == 'bar'"}),
+ ("test2", {"run-if": "foo == 'bar'\nfoo == 'baz'\ndebug"}),
("test3", {"fail-if": "foo == 'bar'"}),
("test4", {"disabled": "some reason"}),
("test5", {"subsuite": "baz"}),
@@ -186,20 +186,34 @@ def test_skip_if(tests):
tests = list(skip_if(tests, {"foo": "bar"}))
assert "disabled" in tests[1]
assert "disabled" in tests[8]
+ # Verify only the matching condition is shown, not all conditions
+ assert tests[1]["disabled"] == "skip-if: foo == 'bar'"
+ assert tests[8]["disabled"] == "skip-if: foo == 'bar'"
def test_run_if(tests):
ref = deepcopy(tests)
tests = list(run_if(tests, {}))
assert "disabled" in tests[2]
+ # For run-if with AND logic, show the first condition that didn't match
+ assert tests[2]["disabled"] == "run-if: foo == 'bar'"
tests = deepcopy(ref)
tests = list(run_if(tests, {"foo": "bar"}))
- assert "disabled" not in tests[2]
+ # Still disabled because foo == 'baz' fails (AND logic)
+ assert "disabled" in tests[2]
+ assert tests[2]["disabled"] == "run-if: foo == 'baz'"
+
+ tests = deepcopy(ref)
+ tests = list(run_if(tests, {"foo": "bar", "debug": True}))
+ # Still disabled because foo == 'baz' fails
+ assert "disabled" in tests[2]
+ assert tests[2]["disabled"] == "run-if: foo == 'baz'"
tests = deepcopy(ref)
tests = list(run_if(tests, {"os": "android", "condprof": False}))
assert "disabled" in tests[9]
+ assert tests[9]["disabled"] == "run-if: os != 'android'"
tests = deepcopy(ref)
tests = list(run_if(tests, {"os": "win", "condprof": False}))
@@ -208,10 +222,12 @@ def test_run_if(tests):
tests = deepcopy(ref)
tests = list(run_if(tests, {"os": "android", "condprof": True}))
assert "disabled" in tests[9]
+ assert tests[9]["disabled"] == "run-if: os != 'android'"
tests = deepcopy(ref)
tests = list(run_if(tests, {"os": "win", "condprof": True}))
assert "disabled" in tests[9]
+ assert tests[9]["disabled"] == "run-if: !condprof"
def test_fail_if(tests):