Repository navigation
feat(jvm): add rtk mvn with Surefire/Failsafe XML test summarization - #1974
bkirosangma wants to merge 2 commits into
Conversation
- Extend dispatch regex in src/discover/rules.rs to include
test|verify|integration-test|failsafe:integration-test, so the Claude
Code Bash hook now rewrites `mvn test` etc. to `rtk mvn test`.
- Add Commands::Mvn variant in main.rs routing to a new cmds::jvm::mvn_cmd
module (auto-discovered via automod::dir!).
- New mvn_cmd.rs:
* Detects task family (Test | Build | Other) from args; honors -X /
--debug / --verbose passthrough per CONTRIBUTING.md "Never Block".
* Test mode: runs mvn, then walks target/{surefire,failsafe}-reports/
for TEST-*.xml files (multi-module aware), parses with quick-xml,
and emits a compact summary:
TESTS: N OK=O FAIL=F ERR=E SKIP=S
FAIL: <classname>.<name> — <80 chars>
ERR: <classname>.<name> — <80 chars>
BUILD SUCCESS/FAILURE + Total time
* Build mode: line filter that strips Maven [INFO] chatter,
Downloading/Downloaded noise, and progress lines, while always
keeping [ERROR], [WARNING], and BUILD/Total/Finished lines.
- New tests/fixtures/mvn_build_noisy_raw.txt — representative noisy mvn
build log for the token-savings assertion (≥60% target).
- 10 new unit tests in mvn_cmd covering: task detection w/ flags, all-pass,
one-failure, one-error, skipped, failsafe, summary formatting, build
filter behavior, token savings ratio.
- 5 new classify/rewrite tests in discover::registry for `mvn test`,
`mvn verify`, `mvn failsafe:integration-test`.
cargo fmt --all && cargo clippy --all-targets && cargo test --bin rtk all pass
(1916 tests, 0 failures).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds the new Maven Surefire/Failsafe entries to the Test Runners section of the top-level README, per CONTRIBUTING.md doc-update map for new Rust filter modules. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
|
|
This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet. |
|
Thanks for this. The Rust mvn module landed as #1956 on 2026-06-08 and was extended by #3199 on 2026-08-30. The file is now built around a log driven filter with per module lanes, caps and mvnd daemon support, so the version proposed here cannot be applied on top of it. One idea from this PR has no equivalent on develop: reading totals and failures from target/surefire-reports and target/failsafe-reports TEST-*.xml as a fallback when the build log cannot be parsed. That would be worth an issue, or a narrow PR adding the fallback inside the current filter. If I missed something, please comment or reopen. |
Summary
Adds
rtk mvn testandrtk mvn verifycoverage for Maven projects, mirroring the existingrtk gradlewdesign. The command runsmvnunchanged, then walkstarget/{surefire,failsafe}-reports/TEST-*.xmlacross all modules and emits a compact, failure-focused summary instead of the raw 10–25 KB Surefire log.src/cmds/jvm/mvn_cmd.rs(~600 LOC, 10 unit tests) auto-discovered viaautomod::dir!.src/discover/rules.rsregex extended so the Bash hook rewritesmvn (test|verify|integration-test|failsafe:integration-test)tortk mvn …(5 new dispatch tests).[INFO],Downloading/Downloaded, progress) is used for non-test goals;[ERROR],[WARNING],BUILD,Total time,Finishedare always preserved.-X,--debug,--verbosetrigger passthrough per the "Never Block" / "Correctness vs Token Savings" principles in CONTRIBUTING.md.Why
mvn testis the most common Maven workflow and produces a large amount of noise the LLM doesn't need: per-module Surefire headers,Tests run: …lines, build banners. On green runs the totals are the only signal; on red runs only the failure rows matter. Parsing the Surefire XML and emitting a short summary fits the same nichertk cargo test/rtk pytest/rtk go testalready occupy for their ecosystems.Token reduction
Measured end-to-end against a synthetic noisy
mvnshim that emits a realistic Surefire log + twoTEST-*.xmlreports (5 tests, 1 failure):i.e. ~95.95% reduction on this fixture. rtk's output is the four lines:
The token-savings unit test in
mvn_cmd.rs(test_build_filter_savings) asserts the build-mode filter alone hits ≥ 60% on a representative noisy build log fixture.Implementation
src/cmds/jvm/mvn_cmd.rs: new module, parses TEST-*.xml withquick-xml(already inCargo.lock).Test | Build | Otherfrom the args list.target/surefire-reports/andtarget/failsafe-reports/.…suffix; up to N rows printed and the rest summarised.src/main.rs: adds aCommands::Mvnvariant routed tocmds::jvm::mvn_cmd::run.src/discover/rules.rs: extends the JVM dispatch regex to includetest|verify|integration-test|failsafe:integration-test.src/discover/registry.rs: 5 new classify/rewrite tests formvn test,mvn verify,mvn failsafe:integration-test.tests/fixtures/mvn_build_noisy_raw.txt: representative noisymvn packagelog used by the build-mode filter savings test.Compatibility
mvn -X/mvn --debug/mvn --verbose→ passthrough (no compression).RTK_DISABLED=1honoured via the existing dispatch path.target/{surefire,failsafe}-reports/recursively from the working directory.mvninvocation is propagated.Test plan
cargo fmt --all --check && cargo clippy --all-targets && cargo test— 1916 passed; 0 failed; 6 ignored (locally on macOS aarch64).src/cmds/jvm/mvn_cmd.rs(10): task detection w/ debug flags, all-pass / one-failure / one-error / skipped / failsafe fixtures, summary formatting, build-mode line filter, build-mode token savings (≥60%), detect-task.src/discover/registry.rs(5):mvn test,mvn verify,mvn failsafe:integration-test.mvn testtortk mvn testvia the Bash hook against a syntheticmvnshim producing the noisy fixture above → ratio = 0.0405.Notes for reviewers
src/cmds/jvm/next togradlew_cmd.rs— symmetric with the existing Gradle filter.quick-xmlis already present.CHANGELOG.mdintentionally untouched — release-please will pick up thefeat(jvm):prefix.