Skip to content

Commit 62a5ace

Browse files
committed
test(complete): Verify some variants of ValueHint
1 parent e648e08 commit 62a5ace

File tree

1 file changed

+52
-0
lines changed
  • clap_complete/tests/testsuite

1 file changed

+52
-0
lines changed

clap_complete/tests/testsuite/bash.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,58 @@ fn complete() {
161161
-V --generate --version quote pacman alias complete "#;
162162
let actual = runtime.complete(input, &term).unwrap();
163163
snapbox::assert_eq(expected, actual);
164+
165+
// Issue 5239 (https://github.com/clap-rs/clap/issues/5239)
166+
let input = "exhaustive hint --file test\t";
167+
let expected = "exhaustive hint --file test % exhaustive hint --file tests ";
168+
let actual = runtime.complete(input, &term).unwrap();
169+
snapbox::assert_eq(expected, actual);
170+
171+
{
172+
use std::fs::File;
173+
use std::path::Path;
174+
175+
let testdir = snapbox::path::PathFixture::mutable_temp().unwrap();
176+
let testdir_path = testdir.path().unwrap();
177+
178+
File::create(Path::new(testdir_path).join("a_file")).unwrap();
179+
File::create(Path::new(testdir_path).join("b_file")).unwrap();
180+
std::fs::create_dir(Path::new(testdir_path).join("c_dir")).unwrap();
181+
std::fs::create_dir(Path::new(testdir_path).join("d_dir")).unwrap();
182+
183+
let input = format!(
184+
"exhaustive hint --file {}/\t\t",
185+
testdir_path.to_string_lossy()
186+
);
187+
let actual = runtime.complete(input.as_str(), &term).unwrap();
188+
assert!(
189+
actual.contains("a_file")
190+
&& actual.contains("b_file")
191+
&& actual.contains("c_dir")
192+
&& actual.contains("d_dir"),
193+
"Actual output:\n{}",
194+
actual
195+
);
196+
197+
let input = format!(
198+
"exhaustive hint --dir {}/\t\t",
199+
testdir_path.to_string_lossy()
200+
);
201+
let actual = runtime.complete(input.as_str(), &term).unwrap();
202+
assert!(
203+
actual.contains("a_file")
204+
&& actual.contains("b_file")
205+
&& actual.contains("c_dir")
206+
&& actual.contains("d_dir"),
207+
"Actual output:\n{}",
208+
actual
209+
);
210+
}
211+
212+
let input = "exhaustive hint --other \t";
213+
let expected = "exhaustive hint --other % exhaustive hint --other ";
214+
let actual = runtime.complete(input, &term).unwrap();
215+
snapbox::assert_eq(expected, actual);
164216
}
165217

166218
#[test]

0 commit comments

Comments
 (0)