Skip to content

Commit

Permalink
test(complete): Verify some variants of ValueHint
Browse files Browse the repository at this point in the history
  • Loading branch information
sudotac committed Jan 20, 2024
1 parent e648e08 commit 62a5ace
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions clap_complete/tests/testsuite/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,58 @@ fn complete() {
-V --generate --version quote pacman alias complete "#;
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);

// Issue 5239 (https://github.com/clap-rs/clap/issues/5239)
let input = "exhaustive hint --file test\t";
let expected = "exhaustive hint --file test % exhaustive hint --file tests ";
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);

{
use std::fs::File;
use std::path::Path;

let testdir = snapbox::path::PathFixture::mutable_temp().unwrap();
let testdir_path = testdir.path().unwrap();

File::create(Path::new(testdir_path).join("a_file")).unwrap();
File::create(Path::new(testdir_path).join("b_file")).unwrap();
std::fs::create_dir(Path::new(testdir_path).join("c_dir")).unwrap();
std::fs::create_dir(Path::new(testdir_path).join("d_dir")).unwrap();

let input = format!(
"exhaustive hint --file {}/\t\t",
testdir_path.to_string_lossy()
);
let actual = runtime.complete(input.as_str(), &term).unwrap();
assert!(
actual.contains("a_file")
&& actual.contains("b_file")
&& actual.contains("c_dir")
&& actual.contains("d_dir"),
"Actual output:\n{}",
actual
);

let input = format!(
"exhaustive hint --dir {}/\t\t",
testdir_path.to_string_lossy()
);
let actual = runtime.complete(input.as_str(), &term).unwrap();
assert!(
actual.contains("a_file")
&& actual.contains("b_file")
&& actual.contains("c_dir")
&& actual.contains("d_dir"),
"Actual output:\n{}",
actual
);
}

let input = "exhaustive hint --other \t";
let expected = "exhaustive hint --other % exhaustive hint --other ";
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
}

#[test]
Expand Down

0 comments on commit 62a5ace

Please sign in to comment.