Skip to content

Evidence: parse pytest summaries from worker output - #28

Merged
JARosen merged 1 commit into
thruwire:mainfrom
tydinjarman:rework/pytest-summary-parsing
Sep 26, 2026
Merged

JARosen merged 1 commit into
thruwire:mainfrom
tydinjarman:rework/pytest-summary-parsing

Conversation

@tydinjarman

Copy link
Copy Markdown
Contributor

Supersedes part of #20, per your review: this is the focused "worker-output test-summary parsing" change, rebased on current main, with no Hermes or policy changes and no helper scripts.

What it does

  • New dependency-free module src/foreman/test_summary.py: frozen PytestSummary dataclass (passed/failed/errored/skipped, total, status with errored > failed > passed precedence, to_dict()), plus parse_pytest_summary_line / parse_pytest_summaries.
  • Handles your explicit case — failure-first "1 failed, 3 passed" — with and without in Ns timing and === wrappers, plus "N error(s)" and skipped counts.
  • Rejects non-summaries (collected 5 items, FAILED ... lines, 2 warnings in 0.12s) instead of guessing.
  • Wired into build_observation: test_results now carries structured entries tagged "source": "worker_output".
  • Named PytestSummary (not TestSummary) so pytest doesn't collect it as a test class.

Validation

Add a small dependency-free parser that turns pytest summary lines into
structured outcomes, and wire it into observation building so the
previously always-empty `test_results` field carries entries tagged
"source": "worker_output".

Handles passed-first and failure-first orderings ("1 failed, 3 passed"),
"N error"/"N errors", skipped counts, with or without the trailing
"in Ns" timing and "=== ... ===" wrappers. Non-summary lines are
rejected (returns None) rather than guessed at. Overall status:
errored > failed > passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants