Skip to content

fix(cargo): preserve libtest list output - #4454

Open
yeahjack wants to merge 16 commits into
rtk-ai:developfrom
yeahjack:fix/cargo-test-list
Open

yeahjack wants to merge 16 commits into
rtk-ai:developfrom
yeahjack:fix/cargo-test-list

Conversation

@yeahjack

@yeahjack yeahjack commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve cargo test -- --list through the existing passthrough runner, including both output streams and Cargo's exit code
  • Detect --list only in libtest's option region, after Cargo's restored -- boundary; do not mistake a flag value or an unclaimed libtest separator's positional argument for a listing request
  • Leave ordinary test-result compression unchanged

Closes #4453. This is separate from #4348's help handling.

Spec-driven re-review

Acceptance was derived from #4453, CONTRIBUTING.md's flag-aware transparency requirement, and libtest's listing contract before inspecting this implementation.

  • C1: Preserve listing stdout/stderr, formatting, and exit status. Covered by single_target_listing_preserves_both_streams, multiple_targets_and_benchmarks_are_not_swallowed, empty_and_terse_listings_preserve_requested_format, compilation_failure_keeps_diagnostics_and_exit_status, and the added listing_preserves_whitespace_and_unterminated_streams (CRLF, no trailing newline, empty output, manifest path containing spaces).
  • C2: Preserve both argument boundaries and distinguish option values. Covered by list_detection_respects_cargo_and_libtest_boundaries and exact spawned-argv assertions.
  • C3: Keep normal compression and shared runner behavior. Covered by ordinary_runs_and_literal_list_arguments_still_use_test_filter; source review confirms the listing branch calls runner::run_passthrough, which preserves signal/exit handling and uses zero-input/zero-output passthrough tracking rather than claiming savings.

The independent pass found one real boundary bug: libtest consumes -- as the value of --skip, so cargo test -- --skip -- --list still requests a listing. The first implementation stopped classifying flags at that value. Native libtest confirms the behavior; the fix uses the existing tokenizer’s claiming_dash_dash() option, with a positive case and a separate unclaimed-boundary negative. libtest_option_can_consume_a_separator_before_list failed on the first implementation (6 pass/1 fail) and passes after the change (7/7). Real Cargo reproductions also pass, including the consumed-value case; six tracking records use the shared zero-savings passthrough accounting. Non-goals remain listing parsing, help/no-capture changes, and unrelated Cargo commands. Cargo shell fixtures execute on Unix only; the recognizer unit test is portable.

Verification

  • cargo fmt --all --check, cargo clippy --offline --all-targets, and cargo test --offline --all passed: 4,121 tests passed; 8 pre-existing ignored tests were not run
  • The 7 focused built-CLI regression tests passed
  • Original develop baseline fails the listing regressions; the added consumed-value case fails on the initial PR and passes after the fix
  • Real Cargo 1.99.0: five listing modes match native stdout and status; compile failure preserves stderr and exits 101; passthrough tracking records no fabricated savings

CI run 37336694478 passed for 81e42531e5200ebd621372a213d3da86d04a3e1b, including Windows/macOS/Linux tests, formatting, clippy, benchmark and security jobs. CLA status passed. The target-branch job is intentionally skipped for the develop base. The optional AI documentation review was skipped because its repository API key is not configured; the job reports success.

The spec-driven self-review has no remaining known in-scope finding. Ready for maintainer review.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working cargo testing labels Oct 5, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes cargo test's passthrough runner to correctly detect cargo test -- --list and forward it to a raw passthrough execution preserving Cargo's exact stdout/stderr/exit code instead of being mangled by normal test-result compression. The detection logic carefully distinguishes libtest's --list flag from positional/value arguments by tokenizing past the correct -- boundary.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4453


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

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

Labels

bug Something isn't working cargo testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk cargo test -- --list prints nothing: the filter reads the test listing as an empty run

1 participant