Repository navigation
Conversation
Maven stdout is not always a complete record of what failed: a forked-VM crash, parallel forks interleaving output, -q, redirected test output or -Dmaven.test.failure.ignore=true can hide per-test detail that target/surefire-reports/TEST-*.xml still carries. After the stdout filter runs (Test / Package / quiet routes), compare the XML-reported failures against the filtered text and append only the ones stdout missed, in [ERROR]-prefixed native style: exception header plus the stack trace verbatim (head-capped), at most CAP_WARNINGS blocks. Restore the 'Tests run:' aggregate from XML when stdout had none. When stdout already covers every XML failure - the common case - output is unchanged byte for byte. Reports older than the run's start are ignored, and the block is appended only while the result still fits under the raw size, so the runner's never-worse guard is never tripped by it. Two modules: surefire_reports (quick-xml streaming parser) and surefire_recovery (diff + render). No new dependencies.
mariuszs
force-pushed
the
feat/mvn-surefire-xml-recovery
branch
from
September 3, 2026 16:24
3464c8f to
707668b
Compare
3 of 8 tasks
romualdbassinot-efficy
added a commit
to romualdbassinot-efficy/rtk
that referenced
this pull request
Sep 20, 2026
Review comment 4058013628 (maven_cmd.rs:1). The module doc comment asserted "with Surefire XML parser". There is no XML handling in the module: nothing reads target/surefire-reports, and every parser here is a regex over Maven's stdout. @mariuszs made the same point on the PR on 2026-09-10. The doc comment now says what the code does - parses Surefire's stdout summary - and names the shapes it therefore cannot recover: a forked-VM crash, -q, redirectTestOutputToFile. It points at rtk-ai#2939, where an XML-backed pass over the report directory is being designed on top of develop's mvn_cmd.rs. The other two copies of the claim: - the CHANGELOG bullet went away with ec3f93d, which reverted the hand-written section wholesale - the PR body is corrected separately, since it is not a file The commit message of 414b48d still reads "Surefire parser", which is defensible on its own terms - it does parse Surefire output, just not the XML - and changing it would need a force-push, which is out of bounds for this round. Verified: cargo test --quiet jvm -- --skip snapshot -> 40 passed, 0 failed Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ures Three ways the recovery pass could append failures that were not missing: - The stdout filter caps its failure list (`… +N more failures`); the elided tests matched nothing in the text and were re-rendered as "missing from build output". Recovery now stays out when a cap tail is present. - Coverage was a plain substring match, so `FooTest.shouldSave:42` covered a missing `shouldSaveAll`, and `com.a.FooTest.m` covered a missing `com.b.FooTest.m`. Names must now stand whole: no identifier character after, no identifier character or package dot before. - Reports were accepted on `mtime >= start` from every module, so a concurrent `-pl other-module` build leaked its failures in. The mtime window now closes at the child's exit, and when stdout announced its classes (`[INFO] Running …`) only those suites are read.
Author
|
Closing this. Following the discussion in #782, I re-tested the motivating cases against a real project (Maven 3.9.16, Surefire 3.5.3, JUnit 5.12), running each through
In all 13 scenarios Without a reproducible case where the XML carries more than stdout, this is ~1000 lines with nothing to recover. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Maven's stdout is not always a complete record of what failed. A forked-VM crash, parallel forks interleaving output,
-q,<redirectTestOutputToFile>, or-Dmaven.test.failure.ignore=truecan hide per-test detail — whiletarget/surefire-reports/TEST-*.xmlstill carries it authoritatively. No stdout filter, however good, can recover what stdout never printed. Today the agent's only options are re-running the build or reading the XML files by hand.What this does
After the stdout filter runs (Test / Package / quiet routes), a post-filter pass parses the fresh
target/surefire-reports/andtarget/failsafe-reports/XML and compares the reported failures against the filtered text:[ERROR]-prefixed native style:Class.method <<< FAILURE!, then the exception header and the stack trace verbatim (head-capped at 30 lines).Tests run:aggregate at all (blind-stdout case), the aggregate line is restored from the XML.Safety rails:
<module>/target/{surefire,failsafe}-reports).CAP_WARNINGSappended blocks (… +N more recovered failurestail), stack traces head-capped.never_worseguard is never tripped by it. When the raw log is too small to fit the block (typically-q), the filtered output is left exactly as today.Example — blind stdout (
-qor a forked-VM crash), two failures only the XML knows about:Implementation
Two modules; the existing filters are untouched — only the three routing arms in
run_tool()go through a smallrun_with_recoverywrapper that appends the pass after the stdout filter:surefire_reports.rsTEST-*.xml(counts, failures, mtime gate)surefire_recovery.rsNo new dependencies —
quick-xmlandtempfileare already inCargo.toml.Scope note (rev 2): this revision is deliberately minimal. The earlier stack-trace collapsing and application-package autodetection (
stack_trace.rs,pom_groupid.rs, ~900 lines) are gone — traces are appended verbatim with a line cap instead — and capturedsystem-out/system-errrecovery was dropped too. Both are possible follow-ups once the core mechanism is in. Rebased onto currentdevelop(mvnd support).Validation
cargo test 'cmds::jvm::surefire_re');cargo test --allshows no new failures against thedevelopbaseline.cargo clippy --all-targetszero warnings; new modules rustfmt-clean../mvnwthat writes a freshTEST-*.xmland prints a forked-VM-crash log: the two XML-only failures are appended after the filtered log (tee hint intact, exit code propagated); the same run with stdout covering the failures is unchanged; under-q(raw too small for the block) the filtered output is left as is.Output cost: zero on every run where stdout already covers the failures; on recovery it adds only the missing failure blocks, capped as above.