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
3 changes: 3 additions & 0 deletions scripts/pr_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def check(body, head, files, is_main_ancestor):
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)")
elif not re.fullmatch(r"0x0+", pr.get("exit", ""), re.I):
problems.append("the PR's regression run needs a successful exit (exit: 0x0), got: "
+ (pr.get("exit") or "missing"))
if main:
m = next((b for b in main if b.get("title") == pr.get("title") and b.get("seconds") == pr.get("seconds")), None)
if m is None:
Expand Down
56 changes: 56 additions & 0 deletions scripts/test_pr_check_smoke_exit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Synthetic checker inputs, not measured regression runs."""
import unittest

import pr_check


HEAD = "a" * 40
BASE = "b" * 40
RUNTIME = [("crates/xcl/src/lib.rs", "modified", False, lambda: 1)]


def block(commit, exit_code):
lines = ["```", "xcl-smoke v1", f"commit: {commit}", "title: synthetic-fixture",
"seconds: 60", "frames shown: 100", "peak commit: 100 MB",
"device removals: 0", "crashes: 0"]
if exit_code is not None:
lines.append(f"exit: {exit_code}")
return "\n".join(lines + ["```"])


def check(pr_exit, base_exit="0x0", files=RUNTIME):
body = "**Tested**\nSynthetic input.\n**Not tested**\nNo title run.\n**AI use**\nNone.\n"
body += block(BASE, base_exit) + "\n" + block(HEAD, pr_exit)
return pr_check.check(body, HEAD, files, lambda sha: sha == BASE)


class SmokeExitTests(unittest.TestCase):
def test_zero_exit_is_accepted(self):
for value in ("0x0", "0x00000000", "0X0"):
with self.subTest(exit=value):
self.assertEqual(check(value), [])

def test_nonzero_exit_is_refused_even_without_logged_crashes(self):
for value in ("0x1", "0xc0000005", "0xffffffff"):
with self.subTest(exit=value):
self.assertTrue(any("exit" in p for p in check(value)))

def test_missing_or_malformed_exit_is_refused(self):
for value in (None, "", "n/a", "0x", "0x0 error"):
with self.subTest(exit=value):
self.assertTrue(any("exit" in p for p in check(value)))

def test_timeout_keeps_its_diagnostic(self):
self.assertIn("the PR's regression run did not end by itself (killed)",
check("killed (no exit)"))

def test_failing_main_is_allowed_when_pr_succeeds(self):
self.assertEqual(check("0x0", base_exit="0xc0000005"), [])

def test_nonruntime_change_does_not_require_smoke(self):
files = [("scripts/example.py", "modified", False, lambda: 1)]
self.assertEqual(check(None, files=files), [])


if __name__ == "__main__":
unittest.main()
Loading