commit feaf6919f740c88f26d085f75b84fc944b23ecbd
parent 5364ec3adbbbe28bc27bbb4cf9862351ebf69a69
Author: Joel Maher <joel.maher@gmail.com>
Date: Mon, 13 Oct 2025 14:06:03 +0000
Bug 1989470 - combine run-if conditions for .toml manifests. r=ci-and-tooling,aryx
Differential Revision: https://phabricator.services.mozilla.com/D268287
Diffstat:
5 files changed, 51 insertions(+), 2 deletions(-)
diff --git a/testing/mozbase/manifestparser/manifestparser/filters.py b/testing/mozbase/manifestparser/manifestparser/filters.py
@@ -45,8 +45,12 @@ 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):
- test.setdefault("disabled", f"{tag}: {test[tag]}")
+ 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]}")
yield test
diff --git a/testing/mozbase/manifestparser/manifestparser/ini.py b/testing/mozbase/manifestparser/manifestparser/ini.py
@@ -190,6 +190,7 @@ def combine_fields(global_vars, local_vars):
field_patterns = {
"args": "%s %s",
"prefs": "%s\n%s",
+ "run-if": "%s\n%s", # consider implicit logical OR: "%s ||\n%s"
"skip-if": "%s\n%s", # consider implicit logical OR: "%s ||\n%s"
"support-files": "%s %s",
"tags": "%s %s",
diff --git a/testing/mozbase/manifestparser/tests/default-runif.toml b/testing/mozbase/manifestparser/tests/default-runif.toml
@@ -0,0 +1,8 @@
+[DEFAULT]
+run-if = "os != 'android'" # a comment
+
+[test7]
+[test8]
+run-if = "!condprof" # another comment
+[test9]
+foo = "bar"
diff --git a/testing/mozbase/manifestparser/tests/test_default_overrides.py b/testing/mozbase/manifestparser/tests/test_default_overrides.py
@@ -79,6 +79,22 @@ class TestDefaultSupportFiles(unittest.TestCase):
self.assertEqual(test["support-files"], expected)
+class TestDefaultRunif(unittest.TestCase):
+ """Tests combining support-files field in [DEFAULT] with the value for a test"""
+
+ def test_defaults_toml(self):
+ default = os.path.join(here, "default-runif.toml")
+ parser = ManifestParser(manifests=(default,), use_toml=True)
+ expected_supp_files = {
+ "test7": "os != 'android'",
+ "test8": "os != 'android'\n!condprof",
+ "test9": "os != 'android'",
+ }
+ for test in parser.tests:
+ expected = expected_supp_files[test["name"]]
+ self.assertEqual(test["run-if"], expected)
+
+
class TestOmitDefaults(unittest.TestCase):
"""Tests passing omit-defaults prevents defaults from propagating to definitions."""
diff --git a/testing/mozbase/manifestparser/tests/test_filters.py b/testing/mozbase/manifestparser/tests/test_filters.py
@@ -170,6 +170,10 @@ def tests(create_tests):
"test8",
{"skip-if": "\nbaz\nfoo == 'bar'\nfoo == 'baz'\nintermittent && debug"},
),
+ (
+ "test9",
+ {"run-if": "os != 'android'\n!condprof"},
+ ),
)
@@ -193,6 +197,22 @@ def test_run_if(tests):
tests = list(run_if(tests, {"foo": "bar"}))
assert "disabled" not in tests[2]
+ tests = deepcopy(ref)
+ tests = list(run_if(tests, {"os": "android", "condprof": False}))
+ assert "disabled" in tests[9]
+
+ tests = deepcopy(ref)
+ tests = list(run_if(tests, {"os": "win", "condprof": False}))
+ assert "disabled" not in tests[9]
+
+ tests = deepcopy(ref)
+ tests = list(run_if(tests, {"os": "android", "condprof": True}))
+ assert "disabled" in tests[9]
+
+ tests = deepcopy(ref)
+ tests = list(run_if(tests, {"os": "win", "condprof": True}))
+ assert "disabled" in tests[9]
+
def test_fail_if(tests):
ref = deepcopy(tests)