Skip to content

fix(cargo): preserve compiler warnings in cargo test output on passing runs#2877

Open
CryptoKrad wants to merge 1 commit into
rtk-ai:developfrom
CryptoKrad:fix/cargo-test-warnings
Open

fix(cargo): preserve compiler warnings in cargo test output on passing runs#2877
CryptoKrad wants to merge 1 commit into
rtk-ai:developfrom
CryptoKrad:fix/cargo-test-warnings

Conversation

@CryptoKrad

Copy link
Copy Markdown

Summary

  • rtk cargo test silently dropped compile-phase warning: blocks on passing runs — an agent reading cargo test: N passed concluded the build was clean while rustc had emitted warnings. Since exit-0 runs get no tee log, the information was unrecoverable (same class as the never_worse size-only guard: the lie is smaller, so it passes).
  • Fix mirrors CargoBuildHandler's warning capture into both paths: CargoTestHandler (streaming) now streams warning blocks live, and filter_cargo_test (buffered/pipe) collects them, capped at CAP_WARNINGS with an +N more marker. The compact summary gains [N compiler warnings]; the aggregate generated N warnings line stays stripped.
  • Buffered path hard-terminates a warning block on section markers (failures: / test result: / test / ---- / error) so a short warning block can never swallow a following section.

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test — fmt clean, clippy 0 issues, 2394 passed / 0 failed (+ integration suites green)
  • 2 new regression tests: test_filter_cargo_test_all_pass_preserves_compiler_warnings (buffered) and test_streamed_cargo_test_handler_preserves_compiler_warnings (streaming) — assert warning survival, [N compiler warnings] annotation, and aggregate-line stripping
  • Manual testing on a crate with a dead-code warning: passing run now shows the warning block + cargo test: 3 passed (2 suites, 0.00s) [1 compiler warnings] (exit 0); failing run still shows failure detail with exit 101 == raw; rtk cargo build output unchanged (consistency restored between build and test)

🤖 Generated with Claude Code

https://claude.ai/code/session_01K5bb4GKf9CNKP9uYhFDvsz

…g runs

What: CargoTestHandler (streaming) and filter_cargo_test (buffered/pipe path)
previously dropped compile-phase 'warning:' blocks entirely on passing runs.
Both now capture and emit warning blocks (mirroring CargoBuildHandler) and
annotate the compact summary with '[N compiler warnings]'. The aggregate
'generated N warnings' count line stays stripped. Buffered path caps blocks
at CAP_WARNINGS with an '+N more' marker and hard-terminates warning blocks
on section markers (failures:/test result:/test /----/error) so short blocks
cannot swallow subsequent sections.

Why: exit-0 runs get no tee log, so dropped warnings were unrecoverable —
an agent reading 'cargo test: N passed' concluded the build was clean when
rustc had emitted warnings. Confirmed behaviorally pre-fix: raw 'cargo test'
showed 3 warning lines; rtk showed none (review lane finding HIGH-2,
docs/research/runs/rtk-review-2026-07-07 in Claude.md-improve).

Verified: cargo test full suite 2394 passed / 0 failed (+ 6 integration
suites green); 2 new tests (buffered + streamed handler) assert warning
survival, warning-count annotation, and aggregate-line stripping; behavioral
A/B on a real crate: passing-with-warnings now shows the block + count
(exit 0), failing run still shows failure detail with exit 101 == raw.

Open risk: pytest wrapper has the analogous success-path loss (warnings
summary + stderr) — tracked as a follow-up, mitigated operationally by
tee.mode=always in local config.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K5bb4GKf9CNKP9uYhFDvsz
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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