(4dea61c) Load the completion script into fish and ask it what it offers, and bump to 0.32.19
Every check over the completions read the script as text. A `contains` cannot tell a rule that fires from one whose condition stopped matching, and that is how a completion actually breaks: the clap definition moves, a list or a `__worklane_command_is` scope stops naming anything, and the rule sits in the file offering nothing while every assertion passes. So the generated script is sourced into a throwaway fish standing in a real board, with this build's directory on the front of PATH, and `complete -C` is compared against the ticket and the tag that board was given. Four deliberate breakages were used to size it: renaming the `ls` status scope, dropping `append` from `TAG_FLAGS`, renaming a flag in `TICKET_FLAGS` and dropping `show` from `TICKET_COMMANDS`. All four now fail, each naming the list at fault. **Assert the values, not the flag names.** clap emits every option's name on its own, so `--tags` and `--blocked-by` are offered with the whole dynamic half deleted; the first draft asserted those names and caught only one of the four. What the hand-written rules add is the candidates after the flag, and that is what a board under the shell makes checkable. Two traps, both paid for once. `complete -C` autoloads `~/.config/fish/completions/worklane.fish`, so the first draft passed against a deliberately broken scope because the copy installed in August still had the working rule: `set fish_complete_path` with no value is what makes the sourced script the only source, and without that line the test cannot fail. And the script is written beside the board rather than in it, since a rule that fires nothing falls back to listing the directory and the script would read as an answer. `fish --no-execute` comes with it as the floor: it catches a script that does not parse. Narrower than it sounds, and measured rather than assumed, so the limit is written on the test. An apostrophe in a `-d` description partway down re-balances against the next quote and parses, corrupting every rule in between; the same apostrophe in the last rule reaches the end unbalanced and is caught. `every_listed_command_is_a_real_subcommand` widens to every list that names a command, `CAMPAIGN_COMMANDS`, `TAG_FLAGS` and the two nested lists, so a stale entry fails by name instead of through a rule count. The counts themselves stay hardcoded and now say why: the walkers go clap → list and never see an extra entry, so the count is what catches one, and deriving it from the lists it checks would grow with the bogus entry and pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
7470255a22
commit
b63b60eefc
+30
-2
@@ -512,8 +512,30 @@ mod tests {
|
||||
fn every_listed_command_is_a_real_subcommand() {
|
||||
let cli = command();
|
||||
let known: Vec<&str> = cli.get_subcommands().map(|c| c.get_name()).collect();
|
||||
for name in TICKET_COMMANDS.iter().chain(TICKET_SECOND_COMMANDS.iter()) {
|
||||
assert!(known.contains(name), "no such subcommand: {name}");
|
||||
|
||||
// Every list that names a top-level command, not only the ticket ones. The others
|
||||
// were reachable only through the rule counts below, which fail with `expected 3,
|
||||
// got 4` and name nothing: a stale entry is a `complete` line whose condition never
|
||||
// matches, so fish offers nothing and says nothing about why.
|
||||
let top = TICKET_COMMANDS
|
||||
.iter()
|
||||
.chain(TICKET_SECOND_COMMANDS.iter())
|
||||
.chain(CAMPAIGN_COMMANDS.iter())
|
||||
.copied()
|
||||
.chain(TAG_FLAGS.iter().map(|(command, _)| *command));
|
||||
|
||||
for name in top {
|
||||
assert!(known.contains(&name), "no such subcommand: {name}");
|
||||
}
|
||||
|
||||
for (parent, child) in CAMPAIGN_NESTED_COMMANDS.iter().chain(TAG_NESTED_COMMANDS.iter()) {
|
||||
let sub = cli
|
||||
.find_subcommand(parent)
|
||||
.unwrap_or_else(|| panic!("no such subcommand: {parent}"));
|
||||
assert!(
|
||||
sub.find_subcommand(child).is_some(),
|
||||
"`worklane {parent}` has no `{child}` subcommand"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,6 +649,12 @@ mod tests {
|
||||
.filter(|line| line.contains("(worklane tags"))
|
||||
.collect();
|
||||
|
||||
// **Hardcoded on purpose, and not derivable from the lists above.** This number is
|
||||
// what catches an entry naming a command or a flag that does not exist: the walkers
|
||||
// go clap → list and never see an extra, so a bogus `("bogus", "nope")` in
|
||||
// `TAG_FLAGS` produces a fourth rule and only this count notices. Writing it as
|
||||
// `TAG_FLAGS.len() + TAG_NESTED_COMMANDS.len()` would grow with the bogus entry and
|
||||
// pass, which is the improvement to not make.
|
||||
assert_eq!(
|
||||
reading.len(),
|
||||
3,
|
||||
|
||||
Reference in New Issue
Block a user