tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 955a5ce240169d7e470717888adff8c8a607659e
parent 6bfa29e7f4ecb6aad63d385f94dbbedeb5e82f28
Author: Florian Quèze <florian@queze.net>
Date:   Fri, 31 Oct 2025 10:20:50 +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:
Mtesting/mozbase/manifestparser/manifestparser/filters.py | 15++++++++++-----
Mtesting/mozbase/manifestparser/tests/test_filters.py | 7++++++-
2 files changed, 16 insertions(+), 6 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,6 +50,7 @@ def run_if(tests, values, strict=False): tag = "run-if" for test in tests: if tag in test and not _match(test[tag], strict, **values): + # For run-if, show all conditions since none of them matched test.setdefault("disabled", f"{tag}: {test[tag]}") 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"}), @@ -182,12 +182,17 @@ 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, all conditions are shown since none matched + assert tests[2]["disabled"] == "run-if: foo == 'bar'\nfoo == 'baz'\ndebug" tests = deepcopy(ref) tests = list(run_if(tests, {"foo": "bar"}))