Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions scripts/run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]] = {}
Expand All @@ -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:]:
Expand All @@ -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:
Expand All @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions tests/test_run_wine_tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Tests for scripts/run_wine_tests.py: path mapping, per-test statuses and the job's exit code.

python -I tests/test_run_wine_tests.py
Expand Down Expand Up @@ -724,6 +724,17 @@
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)
Expand Down
Loading