Skip to content

Commit 19f1b2b

Browse files
committed
test(complete): Test bash dynamic completions
1 parent 2b58b83 commit 19f1b2b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

clap_complete/tests/testsuite/bash.rs

+26
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,29 @@ fn complete() {
167167
fn register_dynamic_completion() {
168168
common::register_example("dynamic", "exhaustive", completest::Shell::Bash);
169169
}
170+
171+
#[test]
172+
#[cfg(all(unix, feature = "unstable-dynamic"))]
173+
fn complete_dynamic() {
174+
if !common::has_command("bash") {
175+
return;
176+
}
177+
178+
let term = completest::Term::new();
179+
let mut runtime = common::load_runtime("dynamic", "exhaustive", completest::Shell::Bash);
180+
181+
let input = "exhaustive \t\t";
182+
let mut expected: Vec<_> = r#"%
183+
action help pacman -h --global
184+
alias hint quote -V --help
185+
complete last value --generate --version"#
186+
.split_whitespace()
187+
.collect();
188+
expected.sort();
189+
let expected = expected.join(" ");
190+
let actual = runtime.complete(input, &term).unwrap();
191+
let mut actual: Vec<_> = actual.split_whitespace().collect();
192+
actual.sort();
193+
let actual = actual.join(" ");
194+
snapbox::assert_eq(expected, actual);
195+
}

clap_complete/tests/testsuite/fish.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ alias help (Print this message or the help of the given subcommand(s)) last
144144
snapbox::assert_eq(expected, actual);
145145
}
146146

147-
#[cfg(feature = "unstable-dynamic")]
147+
#[cfg((unix, feature = "unstable-dynamic"))]
148148
#[test]
149149
fn register_dynamic() {
150150
common::register_example("dynamic", "exhaustive", completest::Shell::Fish);

0 commit comments

Comments
 (0)