Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 40 additions & 3 deletions src/discover/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,11 +1100,48 @@ mod tests {
);
}

#[test]
fn test_classify_cargo_nextest() {
assert_eq!(
classify_command("cargo nextest run"),
Classification::Supported {
rtk_equivalent: "rtk cargo",
category: "Cargo",
estimated_savings_pct: 90.0,
status: RtkStatus::Existing,
}
);
}

#[test]
fn test_rewrite_cargo_nextest() {
assert_eq!(
rewrite_command_no_prefixes("cargo nextest run", &[]),
Some("rtk cargo nextest run".into())
);
}

#[test]
fn test_classify_cargo_nextest_with_args() {
assert_eq!(
classify_command("cargo nextest run --no-fail-fast --release"),
Classification::Supported {
rtk_equivalent: "rtk cargo",
category: "Cargo",
estimated_savings_pct: 90.0,
status: RtkStatus::Existing,
}
);
}

#[test]
fn test_registry_covers_all_cargo_subcommands() {
// Verify that every CargoCommand variant (Build, Test, Clippy, Check, Fmt)
// except Other has a matching pattern in the registry
for subcmd in ["build", "test", "clippy", "check", "fmt"] {
// Verify every cargo subcommand registered in the rule (filter-backed
// CargoCommand variants Build/Test/Clippy/Check/Install/Nextest plus
// the `fmt` passthrough) classifies as Supported.
for subcmd in [
"build", "test", "clippy", "check", "fmt", "install", "nextest",
] {
let cmd = format!("cargo {subcmd}");
match classify_command(&cmd) {
Classification::Supported { .. } => {}
Expand Down
4 changes: 2 additions & 2 deletions src/discover/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ pub const RULES: &[RtkRule] = &[
subcmd_status: &[],
},
RtkRule {
pattern: r"^cargo\s+(build|test|clippy|check|fmt|install)",
pattern: r"^cargo\s+(build|test|clippy|check|fmt|install|nextest)",
rtk_cmd: "rtk cargo",
rewrite_prefixes: &["cargo"],
category: "Cargo",
savings_pct: 80.0,
subcmd_savings: &[("test", 90.0), ("check", 80.0)],
subcmd_savings: &[("test", 90.0), ("check", 80.0), ("nextest", 90.0)],
subcmd_status: &[("fmt", RtkStatus::Passthrough)],
},
RtkRule {
Expand Down