From 1d83fd12b8a2e639a823d17f5aaa127456b6af64 Mon Sep 17 00:00:00 2001 From: emirduran707 Date: Tue, 24 Nov 2026 15:13:15 +0300 Subject: [PATCH] Scripts: pr_check refuses smoke blocks without a title, time or frames check() compares the main and PR xcl-smoke blocks through number(), which gives None for a missing field, and the comparisons let None pass; the title / seconds match compares None == None. Two blocks holding only `xcl-smoke v1` and `commit: ` passed every regression check, though CONTRIBUTING asks for at least 80 % of main's frames and blocks of the same title for the same time. A block that lacks a `title`, `seconds` or `frames shown` line, or has a non-number in one of the last two, is now reported, naming the field and the block's commit: the PR's block, and the main block it is compared with (every main block when none matches). The crash and device-removal counts are left to #635, and the peak commit to #1103. Co-Authored-By: Claude Opus 5.5 --- scripts/pr_check.py | 17 +++++++++++++++++ scripts/test_pr_check.py | 23 +++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/scripts/pr_check.py b/scripts/pr_check.py index 3a526b4a9d..b694f649b0 100644 --- a/scripts/pr_check.py +++ b/scripts/pr_check.py @@ -31,6 +31,10 @@ 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 +SMOKE_FIELDS = ("title", "seconds", "frames shown") +SMOKE_NUMBERS = ("seconds", "frames shown") def smoke_blocks(body): @@ -52,6 +56,16 @@ def number(s): return int(m.group(1)) if m else None +def field_problems(block, run): + """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 a non-numeric `{k}`: {block[k]}" for k in SMOKE_NUMBERS + if block.get(k) and number(block[k]) is None] + return out + + def runtime(path): return path.startswith("crates/xcl/src/") and "/tests" not in path and not path.endswith("tests.rs") @@ -125,6 +139,7 @@ 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") for key in ("device removals", "crashes"): if (number(pr.get(key)) or 0) > 0: problems.append(f"the PR's regression run shows {key}: {pr.get(key)}") @@ -132,6 +147,8 @@ def check(body, head, files, is_main_ancestor, *, test_only=False): problems.append("the PR's regression run did not end by itself (killed)") 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: + problems += field_problems(b, "the main") if m is None: problems.append("the main and PR regression runs are not of the same title for the same time") else: diff --git a/scripts/test_pr_check.py b/scripts/test_pr_check.py index e5de366a54..09099a5bed 100644 --- a/scripts/test_pr_check.py +++ b/scripts/test_pr_check.py @@ -51,8 +51,9 @@ def test_test_paths_do_not_need_approval(self): class SmokeBlockTests(unittest.TestCase): def test_two_blocks_in_one_fence_are_two_blocks(self): - body = ("```\nxcl-smoke v1\ncommit: 1111111aaaa\ntitle: G\nseconds: 60\n\n" - "xcl-smoke v1\ncommit: 1234567890\ntitle: G\nseconds: 60\n```\n") + 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") blocks = smoke_blocks(body) self.assertEqual(["1111111aaaa", "1234567890"], [b["commit"] for b in blocks]) files = [changed("crates/xcl/src/hle/d3d12x/vram.rs")] @@ -63,6 +64,24 @@ def test_blocks_in_separate_fences_stay_separate(self): "```\nxcl-smoke v1\ncommit: 1234567890\ntitle: G\n```\n") self.assertEqual(["1111111aaaa", "1234567890"], [b["commit"] for b in smoke_blocks(body)]) + def smoke_problems(self, main_run, pr_run): + body = ("```\nxcl-smoke v1\ncommit: 1111111aaaa\n" + main_run + "```\n" + "```\nxcl-smoke v1\ncommit: 1234567890\n" + pr_run + "```\n") + files = [changed("crates/xcl/src/hle/d3d12x/vram.rs")] + return check(BODY + body, HEAD, files, lambda sha: sha == "1111111aaaa") + + def test_blocks_with_only_commit_lines_fail(self): + problems = self.smoke_problems("", "") + for field in ("title", "seconds", "frames shown"): + for run in ("the PR's", "the main"): + 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" + 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) + class TemplatePlaceholderTests(unittest.TestCase): def test_untouched_pr_template_fails_all_required_sections(self):