Skip to content

rtk cargo test loses compile diagnostics when tests fail before execution #740

@youbamj

Description

@youbamj

Summary

When cargo test fails during compilation before any test suites run, RTK can lose the main rustc diagnostic context and fall back to a weak tail-output summary.

Reproduction

  1. Introduce a compile error in a test target or crate used by cargo test.
  2. Run:
rtk cargo test

or a focused repro such as:

rtk cargo test --test repro_compile_fail

Example repro file:

#[test]
fn repro_compile_error() {
    let _ = missing_symbol;
}

Actual behavior

On the unfixed path, RTK falls back to truncated tail output and loses the main diagnostic header and source location context:

3 |     let _ = missing_symbol;
  |             ^^^^^^^^^^^^^^ not found in this scope
For more information about this error, try `rustc --explain E0425`.
error: could not compile `rtk` (test "repro_compile_fail") due to 1 previous error
warning: build failed, waiting for other jobs to finish...

Expected behavior

When cargo test fails before test execution begins, RTK should preserve the primary compile diagnostics in a compact cargo test: summary format:

cargo test: 1 errors, 1 warnings (1 crates)
═══════════════════════════════════════
error[E0425]: cannot find value `missing_symbol` in this scope
 --> tests/repro_compile_fail.rs:3:13
  |
3 |     let _ = missing_symbol;
  |             ^^^^^^^^^^^^^^ not found in this scope

warning: build failed, waiting for other jobs to finish...

Impact

This makes compile-failing test runs harder to debug, especially when no test result: summary is produced and the useful rustc error is the most important part of the output.

Proposed fix

Detect compile-error-only cargo test output, reuse the existing build diagnostic formatter, and relabel the summary from cargo build: to cargo test:.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions