Skip to content

Commit d636548

Browse files
Fix test summary extracting full tracebacks
Extract only the "short test summary info" section instead of the full FAILURES section with tracebacks. Reduces real-world output from 45K to 343 lines.
1 parent f9b22f4 commit d636548

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

pr-status/scripts/pr_status.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,30 +261,32 @@ def extract_error_annotations(lines: list[str], *, context: int = 2) -> list[str
261261
def extract_test_summary(lines: list[str]) -> list[str]:
262262
"""Extract test failure summaries from log lines.
263263
264-
Looks for pytest FAILURES sections, FAILED lines, ERROR lines,
265-
and AssertionError occurrences.
264+
Captures the pytest "short test summary info" section (concise)
265+
and individual FAILED/ERROR/AssertionError lines. Avoids capturing
266+
full tracebacks from the FAILURES section.
266267
"""
267268
if not lines:
268269
return []
269270

270271
result: list[str] = []
271272

272-
# Extract pytest FAILURES section
273-
in_failures = False
273+
# Extract pytest "short test summary info" section (concise one-liners)
274+
in_short_summary = False
274275
for line in lines:
275276
stripped = line.strip()
276-
if "=== FAILURES ===" in stripped:
277-
in_failures = True
278-
if in_failures:
277+
if "short test summary info" in stripped:
278+
in_short_summary = True
279279
result.append(line)
280-
if stripped.startswith("===") and "passed" in stripped:
280+
continue
281+
if in_short_summary:
282+
if stripped.startswith("===") or stripped.startswith("---"):
283+
result.append(line)
281284
break
282-
if "=== short test summary info ===" in stripped:
283-
continue
285+
result.append(line)
284286

285287
# Extract individual FAILED / ERROR lines not already captured
286288
seen = set(result)
287-
for i, line in enumerate(lines):
289+
for line in lines:
288290
stripped = line.strip()
289291
if line in seen:
290292
continue

pr-status/scripts/test_pr_status.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,18 +633,21 @@ def test_empty_input(self):
633633
# ---------------------------------------------------------------------------
634634

635635
class TestExtractTestSummary:
636-
def test_extracts_pytest_failures_section(self):
636+
def test_extracts_short_test_summary_section(self):
637637
lines = [
638638
"collecting ...",
639639
"=== FAILURES ===",
640-
"FAILED test_foo.py::test_bar - AssertionError",
640+
"lots of traceback here",
641641
"=== short test summary info ===",
642642
"FAILED test_foo.py::test_bar",
643643
"=== 1 failed, 5 passed ===",
644644
"more stuff",
645645
]
646646
result = extract_test_summary(lines)
647+
assert any("short test summary info" in l for l in result)
647648
assert "FAILED test_foo.py::test_bar" in result
649+
# Should NOT include the full traceback
650+
assert "lots of traceback here" not in result
648651

649652
def test_extracts_failed_lines(self):
650653
lines = [

0 commit comments

Comments
 (0)