mirror of
https://github.com/clap-rs/clap
synced 2024-12-05 02:29:12 +00:00
test(complete): Verify prefix completions
This commit is contained in:
parent
31a4450068
commit
c3e5d16183
4 changed files with 102 additions and 0 deletions
|
@ -281,3 +281,25 @@ fn complete_dynamic_env_quoted_help() {
|
|||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-dynamic"))]
|
||||
fn complete_dynamic_env_option_value() {
|
||||
if !common::has_command("bash") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::BashRuntimeBuilder>("dynamic-env", "exhaustive");
|
||||
|
||||
let input = "exhaustive action --choice=\t\t";
|
||||
let expected = snapbox::str!["% "];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
|
||||
let input = "exhaustive action --choice=f\t";
|
||||
let expected = snapbox::str!["exhaustive action --choice=f % exhaustive action --choice=f"];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
|
|
@ -225,3 +225,33 @@ fn complete_dynamic_env_quoted_help() {
|
|||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-dynamic"))]
|
||||
fn complete_dynamic_env_option_value() {
|
||||
if !common::has_command("elvish") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::ElvishRuntimeBuilder>("dynamic-env", "exhaustive");
|
||||
|
||||
let input = "exhaustive action --choice=\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
% exhaustive action '--choice=first'
|
||||
COMPLETING argument
|
||||
--choice=first --choice=second
|
||||
"#]];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
|
||||
let input = "exhaustive action --choice=f\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
% exhaustive action '--choice=first'
|
||||
COMPLETING argument
|
||||
--choice=first
|
||||
"#]];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
|
|
@ -237,3 +237,28 @@ help (Print this message or the help of the given subcommand(s))
|
|||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-dynamic"))]
|
||||
fn complete_dynamic_env_option_value() {
|
||||
if !common::has_command("fish") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::FishRuntimeBuilder>("dynamic-env", "exhaustive");
|
||||
|
||||
let input = "exhaustive action --choice=\t\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
% exhaustive action --choice=first
|
||||
--choice=first --choice=second
|
||||
"#]];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
|
||||
let input = "exhaustive action --choice=f\t";
|
||||
let expected = snapbox::str!["% exhaustive action --choice=first "];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
|
|
@ -211,3 +211,28 @@ fn complete_dynamic_env_quoted_help() {
|
|||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-dynamic"))]
|
||||
fn complete_dynamic_env_option_value() {
|
||||
if !common::has_command("zsh") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::ZshRuntimeBuilder>("dynamic-env", "exhaustive");
|
||||
|
||||
let input = "exhaustive action --choice=\t\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
% exhaustive action --choice=
|
||||
--choice=first --choice=second
|
||||
"#]];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
|
||||
let input = "exhaustive action --choice=f\t\t";
|
||||
let expected = snapbox::str!["% exhaustive action --choice=first "];
|
||||
let actual = runtime.complete(input, &term).unwrap();
|
||||
assert_data_eq!(actual, expected);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue