Skip to content

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

Closed

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:.

Activity

  1. added
    bug
    effort-small
    filter-quality
    good first issue
    on Mar 20, 2026
  2. pszymkowiak commented on Mar 20, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 92%

    Summary

    RTK's cargo test filter loses primary rustc compile diagnostics when compilation fails before test execution; should reuse build diagnostic formatter with relabeled summary.

    💡 This looks like a simple fix that could be auto-resolved. Use /wshm fix to attempt it.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. aeppling commented on Mar 21, 2026

    @aeppling
    Contributor

    resolved by #738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugeffort-smallfilter-qualitygood first issuepriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions