diff --git a/clap_complete/tests/testsuite/bash.rs b/clap_complete/tests/testsuite/bash.rs index b9692a421c99..53158c9ee8ef 100644 --- a/clap_complete/tests/testsuite/bash.rs +++ b/clap_complete/tests/testsuite/bash.rs @@ -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); +} diff --git a/clap_complete/tests/testsuite/fish.rs b/clap_complete/tests/testsuite/fish.rs index 9f8afbe7e9d4..6e2bbeb46fe4 100644 --- a/clap_complete/tests/testsuite/fish.rs +++ b/clap_complete/tests/testsuite/fish.rs @@ -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);