Skip to content

Commit

Permalink
test(complete): Test bash dynamic completions
Browse files Browse the repository at this point in the history
  • Loading branch information
ModProg committed Jul 29, 2023
1 parent 2b58b83 commit e3babb0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions clap_complete/tests/testsuite/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,29 @@ fn complete() {
fn register_dynamic_completion() {
common::register_example("dynamic", "exhaustive", completest::Shell::Bash);
}

#[test]
#[cfg(all(unix, feature = "unstable-dynamic"))]
fn complete_dynamic() {
if !common::has_command("bash") {
return;
}

let term = completest::Term::new();
let mut runtime = common::load_runtime("dynamic", "exhaustive", completest::Shell::Bash);

let input = "exhaustive \t\t";
let mut expected: Vec<_> = r#"%
action help pacman -h --global
alias hint quote -V --help
complete last value --generate --version"#
.split_whitespace()
.collect();
expected.sort();
let expected = expected.join(" ");
let actual = runtime.complete(input, &term).unwrap();
let mut actual: Vec<_> = actual.split_whitespace().collect();
actual.sort();
let actual = actual.join(" ");
snapbox::assert_eq(expected, actual);
}
2 changes: 1 addition & 1 deletion clap_complete/tests/testsuite/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ alias help (Print this message or the help of the given subcommand(s)) last
snapbox::assert_eq(expected, actual);
}

#[cfg(feature = "unstable-dynamic")]
#[cfg(all(unix, feature = "unstable-dynamic"))]
#[test]
fn register_dynamic() {
common::register_example("dynamic", "exhaustive", completest::Shell::Fish);
Expand Down

0 comments on commit e3babb0

Please sign in to comment.