From ce6c19a522c537e7b83e9fc1f336f22bac89f804 Mon Sep 17 00:00:00 2001 From: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:54:49 +0100 Subject: [PATCH 1/3] ci_expected_failures: a bad argument is one error line with exit 2, not a traceback main() called int(EXIT_STATUS) and open(FAILED_LIST) unguarded, so a workflow step that passed a non-numeric status or a list that does not exist ended in a ValueError/FileNotFoundError traceback (exit 1) instead of naming the argument. Each is now one line on stderr and exit 2, the usage-error code the script already returns for missing arguments. --- scripts/ci_expected_failures.py | 18 ++++++++++++++---- tests/test_ci_expected_failures.py | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/scripts/ci_expected_failures.py b/scripts/ci_expected_failures.py index b07b8de3c6..b01dfd646d 100644 --- a/scripts/ci_expected_failures.py +++ b/scripts/ci_expected_failures.py @@ -4,7 +4,8 @@ FAILED_LIST is a file with one failed test name per line, EXIT_STATUS the test runner's exit status, and each EXPECTED argument one or more whitespace-separated test names (so a workflow can pass one quoted list). Exits 1 when a -test outside EXPECTED failed, or when the runner failed without naming a test (a crash, a build error). An expected +test outside EXPECTED failed, or when the runner failed without naming a test (a crash, a build error); 2 on a usage +error, including a non-integer EXIT_STATUS or a FAILED_LIST that cannot be read, reported as one line. An expected failure that passed gets a GitHub Actions notice, so the list in the workflow can shrink. """ @@ -29,10 +30,19 @@ def main(argv: list[str]) -> int: if len(argv) < 2: print(__doc__.strip(), file=sys.stderr) return 2 - with open(argv[0], encoding="utf-8") as f: - failed = [line.strip() for line in f if line.strip()] + try: + status = int(argv[1]) + except ValueError: + print(f"ci_expected_failures: EXIT_STATUS {argv[1]!r} is not an integer", file=sys.stderr) + return 2 + try: + with open(argv[0], encoding="utf-8") as f: + failed = [line.strip() for line in f if line.strip()] + except OSError as e: + print(f"ci_expected_failures: {argv[0]}: {e.strerror or e}", file=sys.stderr) + return 2 expected = [name for arg in argv[2:] for name in arg.split()] - code, lines = judge(failed, int(argv[1]), expected) + code, lines = judge(failed, status, expected) print("\n".join(lines)) return code diff --git a/tests/test_ci_expected_failures.py b/tests/test_ci_expected_failures.py index 1df4ec2171..edde9b2802 100644 --- a/tests/test_ci_expected_failures.py +++ b/tests/test_ci_expected_failures.py @@ -65,6 +65,25 @@ def test_missing_arguments_is_a_usage_error(self): with contextlib.redirect_stderr(io.StringIO()): self.assertEqual(cef.main([]), 2) + def test_a_list_that_cannot_be_read_is_one_error_line(self): + with tempfile.TemporaryDirectory() as tmp: + missing = Path(tmp) / "absent.txt" + err = io.StringIO() + with contextlib.redirect_stderr(err): + self.assertEqual(cef.main([str(missing), "8"]), 2) + self.assertEqual(err.getvalue().count("\n"), 1) + self.assertIn(str(missing), err.getvalue()) + + def test_a_non_integer_status_is_one_error_line(self): + with tempfile.TemporaryDirectory() as tmp: + path = Path(tmp) / "failed.txt" + path.write_text("a\n", encoding="utf-8") + err = io.StringIO() + with contextlib.redirect_stderr(err): + self.assertEqual(cef.main([str(path), "x"]), 2) + self.assertEqual(err.getvalue().count("\n"), 1) + self.assertIn("'x'", err.getvalue()) + if __name__ == "__main__": unittest.main() From 188c7d43a67159751517861f18f9c46afded4b36 Mon Sep 17 00:00:00 2001 From: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:55:03 +0100 Subject: [PATCH 2/3] ci_expected_failures: --help prints the usage and exits 0 argv0 of -h/--help was counted as a missing argument, so the script printed its docstring to stderr and returned 2. It now prints the same text on stdout and returns 0, like the other scripts under scripts/ and tools/. --- scripts/ci_expected_failures.py | 7 +++++-- tests/test_ci_expected_failures.py | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/ci_expected_failures.py b/scripts/ci_expected_failures.py index b01dfd646d..2e8fafb203 100644 --- a/scripts/ci_expected_failures.py +++ b/scripts/ci_expected_failures.py @@ -5,8 +5,8 @@ FAILED_LIST is a file with one failed test name per line, EXIT_STATUS the test runner's exit status, and each EXPECTED argument one or more whitespace-separated test names (so a workflow can pass one quoted list). Exits 1 when a test outside EXPECTED failed, or when the runner failed without naming a test (a crash, a build error); 2 on a usage -error, including a non-integer EXIT_STATUS or a FAILED_LIST that cannot be read, reported as one line. An expected -failure that passed gets a GitHub Actions notice, so the list in the workflow can shrink. +error, including a non-integer EXIT_STATUS or a FAILED_LIST that cannot be read, reported as one line. `--help` prints +this text. An expected failure that passed gets a GitHub Actions notice, so the list in the workflow can shrink. """ import sys @@ -27,6 +27,9 @@ def judge(failed: list[str], status: int, expected: list[str]) -> tuple[int, lis def main(argv: list[str]) -> int: + if argv and argv[0] in ("-h", "--help"): + print(__doc__.strip()) + return 0 if len(argv) < 2: print(__doc__.strip(), file=sys.stderr) return 2 diff --git a/tests/test_ci_expected_failures.py b/tests/test_ci_expected_failures.py index edde9b2802..ba280bccb0 100644 --- a/tests/test_ci_expected_failures.py +++ b/tests/test_ci_expected_failures.py @@ -65,6 +65,12 @@ def test_missing_arguments_is_a_usage_error(self): with contextlib.redirect_stderr(io.StringIO()): self.assertEqual(cef.main([]), 2) + def test_help_prints_the_usage_and_succeeds(self): + out = io.StringIO() + with contextlib.redirect_stdout(out): + self.assertEqual(cef.main(["--help"]), 0) + self.assertIn("FAILED_LIST EXIT_STATUS", out.getvalue()) + def test_a_list_that_cannot_be_read_is_one_error_line(self): with tempfile.TemporaryDirectory() as tmp: missing = Path(tmp) / "absent.txt" From 685b891eed686e490cf8efcf958115a86249aef1 Mon Sep 17 00:00:00 2001 From: evilclanker9000 <45567075+evilclanker9000@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:55:09 +0100 Subject: [PATCH 3/3] docs/testing: the ci_expected_failures command line, --help and its input-error exit The macOS paragraph named scripts/ci_expected_failures.py without its arguments or what it does with a bad one, so a reader had to open the script to learn the list/status order and that an unreadable list is one line, not a traceback. --- docs/testing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/testing.md b/docs/testing.md index 07ff151255..f279548ceb 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -401,7 +401,9 @@ whose Metal device is "Apple Paravirtual device" (Metal family Mac2, not Apple7) subgroups, so the wave64 and "32 lanes on request" tests skip there (about 75 of 190 in November 2026), and Mesa's KosmicKrisp finds no device. `macos-15` can't build the runtime: Xcode 16's libc++ has no floating-point `std::from_chars`. A test known to fail on MoltenVK is listed in the step's `EXPECTED_FAILURES` with the pull -request or coordination-issue finding that tracks it; it still runs, and `scripts/ci_expected_failures.py` fails the step on any other failure. +request or coordination-issue finding that tracks it; it still runs, and `scripts/ci_expected_failures.py` fails the step +on any other failure. It takes `FAILED_LIST EXIT_STATUS [EXPECTED ...]`, answers `--help`, and reports a list it cannot +read or a non-numeric status as one line with exit code 2. ## GPUs without fragment barycentrics (NVIDIA Volta, Pascal and older)