From 89681182b554706b112ab4e89a3d81a9fbc8a837 Mon Sep 17 00:00:00 2001 From: mokkamokacaffe <329663686+mokkamokacaffe@users.noreply.github.com> Date: Wed, 25 Nov 2026 18:34:56 +0100 Subject: [PATCH] Scripts: require complete successful smoke runs The PR checker treated missing or malformed crash, device-removal, exit, and peak-commit lines as clean values. Require the generated safety fields, parse counters and memory strictly, and accept only a successful 0x0 exit for the PR run.\n\nFixes #2213\n\nAssisted-by: OpenAI Codex (GPT-5) --- scripts/pr_check.py | 27 +++++++++++++++++++-------- scripts/test_pr_check.py | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/scripts/pr_check.py b/scripts/pr_check.py index cb0ef3ef9e..e3c3c8c045 100644 --- a/scripts/pr_check.py +++ b/scripts/pr_check.py @@ -33,10 +33,11 @@ MAX_BINARY = 1 << 20 FRAMES_KEPT = 0.8 # the PR's frames at least this share of main's COMMIT_GROWTH = 1.25 # the PR's peak commit at most this times main's -# the lines a smoke block needs to be compared with the other (the crash and device-removal -# counts are checked where they are used), and those of them that are numbers +# the lines both smoke blocks need for comparison, the additional safety lines the PR's run needs, +# and the comparison fields whose values begin with numbers SMOKE_FIELDS = ("title", "seconds", "frames shown") SMOKE_NUMBERS = ("seconds", "frames shown") +PR_SMOKE_FIELDS = SMOKE_FIELDS + ("device removals", "crashes", "exit", "peak commit") def smoke_blocks(body): @@ -58,11 +59,11 @@ def number(s): return int(m.group(1)) if m else None -def field_problems(block, run): +def field_problems(block, run, fields=SMOKE_FIELDS): """What `block` (the smoke block of `run`) lacks for the comparison: a missing line or a number that is not one.""" name = f"{run} regression run (`xcl-smoke` block of commit {(block.get('commit') or '?').split()[0]})" - out = [f"{name} has no `{k}` line" for k in SMOKE_FIELDS if not block.get(k)] + out = [f"{name} has no `{k}` line" for k in fields if not block.get(k)] out += [f"{name} has a non-numeric `{k}`: {block[k]}" for k in SMOKE_NUMBERS if block.get(k) and number(block[k]) is None] return out @@ -141,12 +142,22 @@ def check(body, head, files, is_main_ancestor, *, test_only=False): "with the same title and time as the PR's") if clean: pr = clean[-1] - problems += field_problems(pr, "the PR's") + problems += field_problems(pr, "the PR's", PR_SMOKE_FIELDS) for key in ("device removals", "crashes"): - if (number(pr.get(key)) or 0) > 0: + value = pr.get(key) + if value and not re.fullmatch(r"\d+", value): + problems.append(f"the PR's regression run has a non-numeric `{key}`: {value}") + elif value and int(value) > 0: problems.append(f"the PR's regression run shows {key}: {pr.get(key)}") - if pr.get("exit", "").startswith("killed"): - problems.append("the PR's regression run did not end by itself (killed)") + exit_code = pr.get("exit") + if exit_code and exit_code != "0x0": + if exit_code.startswith("killed"): + problems.append("the PR's regression run did not end by itself (killed)") + else: + problems.append(f"the PR's regression run exited with {exit_code}, not 0x0") + peak_commit = pr.get("peak commit") + if peak_commit and not re.fullmatch(r"\d+\s+MB", peak_commit): + problems.append(f"the PR's regression run has a non-numeric `peak commit`: {peak_commit}") if main: m = next((b for b in main if b.get("title") == pr.get("title") and b.get("seconds") == pr.get("seconds")), None) for b in [m] if m else main: diff --git a/scripts/test_pr_check.py b/scripts/test_pr_check.py index 8cc45d5d06..02111b6859 100644 --- a/scripts/test_pr_check.py +++ b/scripts/test_pr_check.py @@ -70,10 +70,12 @@ def test_frontier_models_and_ordinary_words_pass(self): class SmokeBlockTests(unittest.TestCase): + RUN = ("title: G\nseconds: 60\nexit: 0x0\nframes shown: 100\n" + "device removals: 0\ncrashes: 0\npeak commit: 1000 MB\n") + def test_two_blocks_in_one_fence_are_two_blocks(self): - run = "title: G\nseconds: 60\nframes shown: 100\ndevice removals: 0\ncrashes: 0\n" - body = ("```\nxcl-smoke v1\ncommit: 1111111aaaa\n" + run + "\n" - "xcl-smoke v1\ncommit: 1234567890\n" + run + "```\n") + body = ("```\nxcl-smoke v1\ncommit: 1111111aaaa\n" + self.RUN + "\n" + "xcl-smoke v1\ncommit: 1234567890\n" + self.RUN + "```\n") blocks = smoke_blocks(body) self.assertEqual(["1111111aaaa", "1234567890"], [b["commit"] for b in blocks]) files = [changed("crates/xcl/src/hle/d3d12x/vram.rs")] @@ -97,11 +99,35 @@ def test_blocks_with_only_commit_lines_fail(self): self.assertTrue(any(p.startswith(run) and f"no `{field}` line" in p for p in problems), problems) def test_non_numeric_frames_shown_fails(self): - run = "title: G\nseconds: 60\ndevice removals: 0\ncrashes: 0\n" + run = self.RUN.replace("frames shown: 100\n", "") problems = self.smoke_problems(run + "frames shown: 100\n", run + "frames shown: many\n") self.assertIn("the PR's regression run (`xcl-smoke` block of commit 1234567890) " "has a non-numeric `frames shown`: many", problems) + def test_pr_block_requires_safety_fields(self): + for field in ("device removals", "crashes", "exit", "peak commit"): + with self.subTest(field=field): + pr_run = "\n".join(line for line in self.RUN.splitlines() + if not line.startswith(field + ":")) + "\n" + problems = self.smoke_problems(self.RUN, pr_run) + self.assertTrue(any(p.startswith("the PR's") and f"no `{field}` line" in p + for p in problems), problems) + + def test_pr_block_rejects_invalid_safety_values(self): + cases = { + "device removals: none": "non-numeric `device removals`", + "crashes: none": "non-numeric `crashes`", + "exit: 0xc0000005": "exited with 0xc0000005, not 0x0", + "peak commit: n/a MB": "non-numeric `peak commit`", + } + for replacement, expected in cases.items(): + with self.subTest(replacement=replacement): + field = replacement.split(":", 1)[0] + pr_run = "\n".join(replacement if line.startswith(field + ":") else line + for line in self.RUN.splitlines()) + "\n" + problems = self.smoke_problems(self.RUN, pr_run) + self.assertTrue(any(expected in p for p in problems), problems) + class TemplatePlaceholderTests(unittest.TestCase): def test_untouched_pr_template_fails_all_required_sections(self):