Answer stability round 1: 1 🔴, 12 🟡 (0 misread); wait-for waits out a half-written line, prepare-scoring honours claudeMdExcludes, and a merge by another method waits for the checks
CI / tests (pull_request) Successful in 2m38s

This commit is contained in:
2026-11-12 09:13:37 +01:00
parent 37f19d1677
commit 58133e69fe
8 changed files with 90 additions and 23 deletions
+17 -6
View File
@@ -4,7 +4,6 @@ import pathlib
import subprocess
import sys
import tempfile
import threading
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
@@ -59,6 +58,17 @@ class WaitFor(unittest.TestCase):
def test_gives_up_on_a_file_that_never_appears(self):
self.assertEqual(main.waited(str(self.file), None, 5, Clock()), Failure(f"{self.file} did not appear in 5 s"))
def test_waits_for_a_half_written_last_line_to_end(self):
self.file.write_text("running\n== 3 passed in")
clock = Clock(lambda: self.file.write_text("running\n== 3 passed in 1s ==\n"))
self.assertEqual(main.waited(str(self.file), "passed", 60, clock), "== 3 passed in 1s ==")
def test_takes_a_last_line_without_a_newline_once_a_poll_finds_it_unchanged(self):
self.file.write_text("# Report\nNo findings.")
clock = Clock()
self.assertEqual(main.waited(str(self.file), None, 60, clock), "No findings.")
self.assertEqual(clock.now, main.POLL_SECONDS)
def test_reads_a_line_that_is_not_utf_8(self):
self.file.write_bytes(b"caf\xe9 passed\n")
self.assertEqual(main.waited(str(self.file), "passed", 60, Clock()), "caf\ufffd passed")
@@ -85,6 +95,8 @@ class WaitFor(unittest.TestCase):
for argv, expected in (
([str(self.file), "passed", "--timeout", "5"], (0, "== 1 passed ==\n", "")),
(["--help"], (0, main.__doc__.strip() + "\n", "")),
(["-h"], (0, main.__doc__.strip() + "\n", "")),
(["--help", str(self.file)], (0, main.__doc__.strip() + "\n", "")),
([str(self.file), "("], (1, "", "wait-for: cannot read the pattern `(`: missing ), unterminated subpattern at position 0\n")),
):
with self.subTest(argv=argv):
@@ -96,6 +108,7 @@ class WaitFor(unittest.TestCase):
def test_arguments_take_the_timeout_anywhere_and_refuse_a_bad_one(self):
self.assertEqual(main.arguments(["--timeout", "1.5", "f", "p"]), ("f", "p", 1.5))
self.assertEqual(main.arguments(["f"]), ("f", None, 540.0))
self.assertEqual(main.arguments(["f", "--timeout", "0.5"]), ("f", None, 0.5))
for timeout in ("0", "-1", "x", "1.", None):
with self.subTest(timeout=timeout):
argv = ["f", "--timeout"] + ([timeout] if timeout else [])
@@ -104,11 +117,9 @@ class WaitFor(unittest.TestCase):
with self.subTest(argv=argv):
self.assertEqual(main.arguments(argv), Failure(main.USAGE))
def test_the_command_waits_for_a_file_another_process_writes(self):
writer = threading.Timer(0.5, lambda: self.file.write_text("== 1 passed in 0.1s ==\n"))
writer.start()
self.addCleanup(writer.cancel)
result = subprocess.run([sys.executable, str(TOOL), str(self.file), "passed", "--timeout", "20"], capture_output=True, text=True)
def test_the_command_prints_the_line_a_file_holds(self):
self.file.write_text("== 1 passed in 0.1s ==\n")
result = subprocess.run([sys.executable, str(TOOL), str(self.file), "passed", "--timeout", "20"], capture_output=True, text=True, timeout=10)
self.assertEqual((result.returncode, result.stdout, result.stderr), (0, "== 1 passed in 0.1s ==\n", ""))
def test_refuses_a_bad_pattern_timeout_or_argument_count_waiting_for_nothing(self):