Answer stability round 2: 0 🔴, 0 🟡 (0 misread); take a failed subtest's message over what its parent logged

This commit is contained in:
2026-11-21 03:37:59 +01:00
parent 0c17559efe
commit 1500c52d69
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -105,7 +105,7 @@ def line_at_head(diff: str, line: int) -> int | None:
def task_text(output: str) -> str | None:
"""What Haiku is told of a planted bug: the failing assertion's message in go test's output, without the test's name, file or
line, so it says what goes wrong and not where. That is the last message of the first failed test that printed one, since a
test logs before it asserts. None where no failed test printed a message, as on a panic, a build that broke or a passing run,
test logs before it asserts; a test with a failed subtest is left out, since it fails with the subtest. None where no failed test printed a message, as on a panic, a build that broke or a passing run,
or where the message only names the test."""
lines = output.splitlines()
failed = set(FAILED_TEST.findall(output))
@@ -119,7 +119,7 @@ def task_text(output: str) -> str | None:
elif printed := PRINTED.match(line):
# A test's output is indented deeper than its mark, so a line after a subtest's may be its parent's.
test = next((name for indent, name in reversed(marks) if indent < len(printed[1])), None)
if test is not None and test in failed:
if test is not None and test in failed and not any(other.startswith(f"{test}/") for other in failed):
last[test] = index, printed
if not last:
return None
+4
View File
@@ -128,6 +128,10 @@ class TaskTextTest(unittest.TestCase):
self.assertEqual(task_text(" setup_test.go:3: starting\n--- FAIL: TestPick (0.00s)\n pick_test.go:42: got 3\nFAIL\n"), "got 3")
self.assertIsNone(task_text(" setup_test.go:3: starting\n--- FAIL: TestPick (0.00s)\nFAIL\n"))
def test_takes_the_failed_subtests_message_over_what_its_parent_logged_before_it(self):
output = "--- FAIL: TestPick (0.00s)\n pick_test.go:10: three cases\n --- FAIL: TestPick/empty (0.00s)\n pick_test.go:42: got 3\nFAIL\n"
self.assertEqual(task_text(output), "got 3")
def test_is_none_where_only_passing_tests_logged(self):
self.assertIsNone(task_text("=== RUN TestServer\n server_test.go:12: listening\n--- PASS: TestServer (0.00s)\nPASS\n"))