Skip to content

Commit f8bc08e

Browse files
committed
fix(discover): add cargo nextest to rewrite rule
`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 #2046
1 parent 5a149a7 commit f8bc08e

2 files changed

Lines changed: 41 additions & 5 deletions

File tree

src/discover/registry.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,11 +1100,47 @@ mod tests {
11001100
);
11011101
}
11021102

1103+
#[test]
1104+
fn test_classify_cargo_nextest() {
1105+
assert_eq!(
1106+
classify_command("cargo nextest run"),
1107+
Classification::Supported {
1108+
rtk_equivalent: "rtk cargo",
1109+
category: "Cargo",
1110+
estimated_savings_pct: 90.0,
1111+
status: RtkStatus::Existing,
1112+
}
1113+
);
1114+
}
1115+
1116+
#[test]
1117+
fn test_rewrite_cargo_nextest() {
1118+
assert_eq!(
1119+
rewrite_command_no_prefixes("cargo nextest run", &[]),
1120+
Some("rtk cargo nextest run".into())
1121+
);
1122+
}
1123+
1124+
#[test]
1125+
fn test_classify_cargo_nextest_with_args() {
1126+
assert_eq!(
1127+
classify_command("cargo nextest run --no-fail-fast --release"),
1128+
Classification::Supported {
1129+
rtk_equivalent: "rtk cargo",
1130+
category: "Cargo",
1131+
estimated_savings_pct: 90.0,
1132+
status: RtkStatus::Existing,
1133+
}
1134+
);
1135+
}
1136+
11031137
#[test]
11041138
fn test_registry_covers_all_cargo_subcommands() {
1105-
// Verify that every CargoCommand variant (Build, Test, Clippy, Check, Fmt)
1106-
// except Other has a matching pattern in the registry
1107-
for subcmd in ["build", "test", "clippy", "check", "fmt"] {
1139+
// Verify that every CargoCommand variant (Build, Test, Clippy, Check, Fmt,
1140+
// Install, Nextest) except Other has a matching pattern in the registry.
1141+
for subcmd in [
1142+
"build", "test", "clippy", "check", "fmt", "install", "nextest",
1143+
] {
11081144
let cmd = format!("cargo {subcmd}");
11091145
match classify_command(&cmd) {
11101146
Classification::Supported { .. } => {}

src/discover/rules.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ pub const RULES: &[RtkRule] = &[
4444
subcmd_status: &[],
4545
},
4646
RtkRule {
47-
pattern: r"^cargo\s+(build|test|clippy|check|fmt|install)",
47+
pattern: r"^cargo\s+(build|test|clippy|check|fmt|install|nextest)",
4848
rtk_cmd: "rtk cargo",
4949
rewrite_prefixes: &["cargo"],
5050
category: "Cargo",
5151
savings_pct: 80.0,
52-
subcmd_savings: &[("test", 90.0), ("check", 80.0)],
52+
subcmd_savings: &[("test", 90.0), ("check", 80.0), ("nextest", 90.0)],
5353
subcmd_status: &[("fmt", RtkStatus::Passthrough)],
5454
},
5555
RtkRule {

0 commit comments

Comments
 (0)