Skip to content

Commit f1caf3d

Browse files
committed
test(cli): expand legacy-flag rejection guard to all 19 removed flags
Per code review feedback, the original guard only checked --claude. Make the test table-driven over every removed flag, with --synthetic called out explicitly because it is the only legacy flag that did not have a matching ClientId — its handling has always been special-cased and is the most likely surface to regress if anyone resurrects the boolean fields. Also adds a positive sanity sweep to ensure --client opencode / claude / synthetic still parse, so the test does not silently pass via an over-tight parser.
1 parent 52b7b11 commit f1caf3d

1 file changed

Lines changed: 47 additions & 11 deletions

File tree

crates/tokscale-cli/src/main.rs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4313,19 +4313,55 @@ mod tests {
43134313

43144314
#[test]
43154315
fn test_client_flags_legacy_long_flags_rejected() {
4316-
// After the major bump that removed legacy flags, `--claude` and
4317-
// friends must produce a clap parse error instead of silently
4318-
// mutating filter state. Guards the removal.
4319-
match Cli::try_parse_from(["tokscale", "--claude"]) {
4320-
Ok(_) => panic!("legacy --claude must no longer parse"),
4321-
Err(err) => {
4322-
let rendered = err.to_string();
4323-
assert!(
4324-
rendered.contains("--claude") || rendered.contains("unexpected"),
4325-
"expected an unexpected-argument error, got: {rendered}"
4326-
);
4316+
// After the major bump that removed legacy flags, every old
4317+
// `--<client>` form must produce a clap parse error instead of
4318+
// silently mutating filter state. Table-driven so a future
4319+
// resurrection of any single flag (regression risk: someone
4320+
// adds `pub claude: bool` back to ClientFlags) is caught
4321+
// immediately.
4322+
//
4323+
// `--synthetic` is included explicitly because it is the only
4324+
// legacy flag without a matching `ClientId` — its handling has
4325+
// always been special-cased and is the most likely to regress.
4326+
for legacy in [
4327+
"--opencode",
4328+
"--claude",
4329+
"--codex",
4330+
"--copilot",
4331+
"--gemini",
4332+
"--cursor",
4333+
"--amp",
4334+
"--droid",
4335+
"--openclaw",
4336+
"--hermes",
4337+
"--pi",
4338+
"--kimi",
4339+
"--qwen",
4340+
"--roocode",
4341+
"--kilocode",
4342+
"--kilo",
4343+
"--mux",
4344+
"--crush",
4345+
"--synthetic",
4346+
] {
4347+
match Cli::try_parse_from(["tokscale", legacy]) {
4348+
Ok(_) => panic!("legacy {legacy} must no longer parse"),
4349+
Err(err) => {
4350+
let rendered = err.to_string();
4351+
assert!(
4352+
rendered.contains(legacy) || rendered.contains("unexpected"),
4353+
"expected an unexpected-argument error for {legacy}, got: {rendered}"
4354+
);
4355+
}
43274356
}
43284357
}
4358+
4359+
// Sanity: the canonical replacement still parses for the same
4360+
// values so we have not over-tightened the parser.
4361+
for canonical in ["opencode", "claude", "synthetic"] {
4362+
Cli::try_parse_from(["tokscale", "--client", canonical])
4363+
.unwrap_or_else(|e| panic!("--client {canonical} must still parse: {e}"));
4364+
}
43294365
}
43304366

43314367
#[test]

0 commit comments

Comments
 (0)