Skip to content
Open
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
13 changes: 9 additions & 4 deletions scripts/pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
# 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")
# what smoke.ps1 writes as `frames shown` when the run did not reach its end (a crash)
FRAMES_UNENDED = "none logged"


def smoke_blocks(body):
Expand All @@ -58,13 +60,16 @@ def number(s):
return int(m.group(1)) if m else None


def field_problems(block, run):
def field_problems(block, run, *, may_crash=False):
"""What `block` (the smoke block of `run`) lacks for the comparison: a missing line or a
number that is not one."""
number that is not one. `may_crash`: main's run, which may not have reached its end
(CONTRIBUTING.md: a PR that fixes a crash shows it there), so smoke.ps1's text for that
is accepted as its `frames shown`."""
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]
if block.get(k) and number(block[k]) is None
and not (may_crash and k == "frames shown" and block[k].startswith(FRAMES_UNENDED))]
return out


Expand Down Expand Up @@ -150,7 +155,7 @@ def check(body, head, files, is_main_ancestor, *, test_only=False):
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")
problems += field_problems(b, "the main", may_crash=True)
if m is None:
problems.append("the main and PR regression runs are not of the same title for the same time")
else:
Expand Down
13 changes: 13 additions & 0 deletions scripts/test_pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ def test_non_numeric_frames_shown_fails(self):
self.assertIn("the PR's regression run (`xcl-smoke` block of commit 1234567890) "
"has a non-numeric `frames shown`: many", problems)

def test_main_run_that_crashed_before_its_end_passes(self):
# smoke.ps1's text when the run did not reach its end; a crash-fix PR shows it on main
unended = "frames shown: none logged (the run did not reach its end)\n"
main_run = "title: G\nseconds: 60\ndevice removals: 0\ncrashes: 1\nexit: 0xc0000005\n" + unended
pr_run = "title: G\nseconds: 60\nframes shown: 100\ndevice removals: 0\ncrashes: 0\n"
self.assertEqual([], self.smoke_problems(main_run, pr_run))

def test_pr_run_that_did_not_reach_its_end_still_fails(self):
run = "title: G\nseconds: 60\ndevice removals: 0\ncrashes: 0\n"
unended = "frames shown: none logged (the run did not reach its end)\n"
problems = self.smoke_problems(run + "frames shown: 100\n", run + unended)
self.assertTrue(any(p.startswith("the PR's") and "non-numeric `frames shown`" in p for p in problems), problems)


class TemplatePlaceholderTests(unittest.TestCase):
def test_untouched_pr_template_fails_all_required_sections(self):
Expand Down
Loading