Skip to content

fix(discover): add cargo nextest to rewrite rule#2122

Open
maxmilian wants to merge 1 commit into
rtk-ai:developfrom
maxmilian:fix/discover-cargo-nextest
Open

fix(discover): add cargo nextest to rewrite rule#2122
maxmilian wants to merge 1 commit into
rtk-ai:developfrom
maxmilian:fix/discover-cargo-nextest

Conversation

@maxmilian

Copy link
Copy Markdown

Summary

Root cause

src/discover/rules.rs:47 — the cargo rule's pattern alternation only matched (build|test|clippy|check|fmt|install). nextest was missing, so RegexSet never matched cargo nextest … and classify_command fell through to Unsupported.

Fix

  • Add nextest to the alternation: ^cargo\s+(build|test|clippy|check|fmt|install|nextest).
  • Register (\"nextest\", 90.0) in subcmd_savings, matching test (both filters reduce to a one-line pass/fail summary, see filter_cargo_nextest in src/cmds/rust/cargo_cmd.rs:583).
  • No changes to rewrite_prefixes or subcmd_statusnextest reuses cargo's existing prefix and is Existing (not passthrough).

Tests

  • cargo fmt --all --check — clean
  • cargo clippy --all-targets — 0 warnings
  • cargo test --all — 1948 passed, 0 failed (2 new tests included)
  • New unit tests in src/discover/registry.rs:
    • test_classify_cargo_nextestcargo nextest runSupported { rtk_equivalent: \"rtk cargo\", category: \"Cargo\", estimated_savings_pct: 90.0, status: Existing }
    • test_rewrite_cargo_nextestcargo nextest runrtk cargo nextest run
  • Manual repro (release build):
    • Before: rtk rewrite \"cargo nextest run\" → empty output, EC=1
    • After: rtk rewrite \"cargo nextest run\"rtk cargo nextest run, EC=3 (matches cargo test / cargo build baseline; reporter's expected EC=0 was a minor misstatement — EC=3 is RTK's normal "rewrite suggested" status)

Scope

  • Does not touch src/cmds/rust/cargo_cmd.rs — the nextest filter already exists and is reachable as rtk cargo nextest once routed via Clap.
  • Does not add nextest to rewrite_prefixes (cargo invocations always start with literal cargo; no aliases needed).

@maxmilian maxmilian force-pushed the fix/discover-cargo-nextest branch from b8a57c9 to f8bc08e Compare May 27, 2026 15:11
`rtk cargo nextest` is implemented in src/cmds/rust/cargo_cmd.rs with
dedicated filtered output, but the discover rewrite pattern only matched
`cargo (build|test|clippy|check|fmt|install)`. The Claude Code hook
therefore never rewrote `cargo nextest` calls, so users invoking nextest
directly received raw output instead of RTK's compact summary.

Changes:
- Add `nextest` to the cargo pattern alternation in src/discover/rules.rs
- Register `("nextest", 90.0)` in subcmd_savings (matches `test`, since
  both filters collapse to a one-line pass/fail summary)
- Add classify + rewrite + with-args tests in src/discover/registry.rs
- Update `test_registry_covers_all_cargo_subcommands` to include
  `install` and `nextest` (the loop had drifted out of sync with the
  CargoCommand enum when `Install` was added previously)

Closes rtk-ai#2046
@maxmilian maxmilian force-pushed the fix/discover-cargo-nextest branch from f8bc08e to 226b676 Compare May 27, 2026 16:05
@maxmilian maxmilian marked this pull request as ready for review May 27, 2026 16:05
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.

cargo nextest rewrite rule missing from registry despite subcommand existing

1 participant