Skip to content

fix(cargo): preserve inline panic output under test --nocapture - #5405

Open
MasihMoafi wants to merge 1 commit into
rtk-ai:developfrom
MasihMoafi:fix/cargo-test-nocapture-panics
Open

MasihMoafi wants to merge 1 commit into
rtk-ai:developfrom
MasihMoafi:fix/cargo-test-nocapture-panics

Conversation

@MasihMoafi

Copy link
Copy Markdown

Closes #5063.

Problem

With cargo test -- --nocapture, the test harness prints a failing test panic inline before the failures: list without a ---- name stdout ---- section. CargoTestHandler::is_block_start only captured blocks starting with ---- inside failures:, dropping the panic location and assertion message.

Fix

  • Detect inline Rust panic headers (thread ... panicked at ) in CargoTestHandler::is_block_start outside the failures: section and keep their body lines until a blank line, test status line, failures:, or test result:.
  • Add a regression test verifying cargo test -- --nocapture preserves the panic header, assertion message, left/right values, and failure summary.

Verification

  • cargo fmt --check
  • cargo test --lib cargo_cmd (93 passed, 0 failed)

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.

rtk cargo test -- --nocapture drops the panic message of a failing test

1 participant