From 59a51c2c79d4075afb325a214f0f212fc928a133 Mon Sep 17 00:00:00 2001 From: TheGeogeo <57634077+TheGeogeo@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:42:05 +0100 Subject: [PATCH] run_wine_tests: retain results for repeated test names --- scripts/run_wine_tests.py | 20 ++++++++++---------- tests/test_run_wine_tests.py | 11 +++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py index d360114303..393b17ce93 100644 --- a/scripts/run_wine_tests.py +++ b/scripts/run_wine_tests.py @@ -12,8 +12,8 @@ runtime/build/generated). For those, the drive of --windows-root is pointed at --root in the Wine prefix for the run ($WINEPREFIX, else ~/.wine), unless that drive is already in use there. -Every test is reported. The exit code is 1 if a test named by --require fails or is missing, else 0: the -others show what does and doesn't work under Wine yet without failing the job. +Every test is reported. Each name given to --require must be listed and all of its tests must pass, or the +exit code is 1. The other results show what does and doesn't work under Wine yet without failing the job. --timeout caps each process; a shorter positive CTest TIMEOUT takes precedence for that test. Relative executable paths in --wine or WINE are read from the directory where you start this runner. @@ -515,7 +515,7 @@ def main() -> int: ap.add_argument("--root", type=os.path.abspath, default=ROOT, help="the Linux checkout (default: this repository)") ap.add_argument("--wine", type=wine_command, default=os.environ.get("WINE", "wine"), help="Wine command (default: $WINE or wine)") - ap.add_argument("--require", action="append", default=[], help="a test that must pass (repeatable)") + ap.add_argument("--require", action="append", default=[], help="a test name whose entries must all pass (repeatable)") ap.add_argument("--timeout", type=positive_seconds, default=120.0, help="maximum seconds per test; a shorter CTest TIMEOUT applies (default 120)") ap.add_argument("--jobs", type=positive_int, default=1, @@ -546,7 +546,6 @@ def main() -> int: # Each test starts in its own CTest working directory. Keep bare commands on PATH. if os.path.dirname(wine[0]) and not os.path.isabs(wine[0]): wine[0] = os.path.join(os.getcwd(), wine[0]) - results = {} results_by_index: dict[int, str] = {} prefix = os.environ.get("WINEPREFIX") or os.path.join(os.path.expanduser("~"), ".wine") outcomes: dict[int, tuple[str, str]] = {} @@ -557,7 +556,6 @@ def run_one(index: int) -> tuple[str, str]: def report(index: int) -> None: status, detail = outcomes[index] - results[names[index]] = status print(f"[{status.upper()}] {names[index]}", flush=True) if status != "pass": for line in detail.rstrip().splitlines()[-40:]: @@ -574,11 +572,12 @@ def report(index: int) -> None: else: run_parallel(tests, order, before, args.jobs, run_one, outcomes, results_by_index, report) - missing = list(dict.fromkeys(n for n in args.require if n not in results)) - failed_required = [n for n in args.require if results.get(n) != "pass"] - counts = {s: sum(1 for v in results.values() if v == s) for s in ("pass", "fail", "skip")} + missing = list(dict.fromkeys(n for n in args.require if n not in indices)) + nonpassing_names = {names[index] for index, status in results_by_index.items() if status != "pass"} + failed_required = [n for n in args.require if n not in indices or n in nonpassing_names] + counts = {s: sum(1 for v in results_by_index.values() if v == s) for s in ("pass", "fail", "skip")} print(f"\n{counts['pass']} passed, {counts['fail']} failed, {counts['skip']} skipped under Wine " - f"({len(results)} tests)") + f"({len(results_by_index)} tests)") for n in missing: print(f"required test not listed by the Windows build: {n}") if failed_required: @@ -591,7 +590,8 @@ def report(index: int) -> None: f.write(f"### Windows tests under {args.label or 'Wine'}\n\n") f.write(f"{counts['pass']} passed, {counts['fail']} failed, {counts['skip']} skipped.\n\n") f.write("| Test | Result | Required |\n|---|---|---|\n") - for name, status in results.items(): + for index in order: + name, status = names[index], results_by_index[index] f.write(f"| `{name}` | {status} | {'yes' if name in args.require else ''} |\n") for name in missing: # The job fails on these, so the table must name them, not only the log. diff --git a/tests/test_run_wine_tests.py b/tests/test_run_wine_tests.py index 7ba55d2f8e..ea137231fc 100644 --- a/tests/test_run_wine_tests.py +++ b/tests/test_run_wine_tests.py @@ -724,6 +724,17 @@ def test_a_required_test_that_fails_exits_one(self): self.assertEqual(code, 1) self.assertIn("required tests that did not pass: bad", out) + def test_required_name_checks_every_result_with_that_name(self): + entries = [ctest_entry("shared", self.command("bad.py")), + ctest_entry("shared", self.command("ok.py"))] + summary = self.root / "summary.md" + code, out, _ = self.run_main(entries, "--require", "shared", "--summary", str(summary)) + self.assertEqual(code, 1, out) + self.assertIn("1 passed, 1 failed, 0 skipped under Wine (2 tests)", out) + self.assertIn("required tests that did not pass: shared", out) + table = summary.read_text(encoding="utf-8") + self.assertIn("| `shared` | fail | yes |\n| `shared` | pass | yes |", table) + def test_a_required_test_that_is_not_listed_exits_one(self): code, out, _ = self.run_main([ctest_entry("ok", self.command("ok.py"))], "--require", "absent") self.assertEqual(code, 1)