mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 06:44:16 +00:00
test(complete): Specialize tests
This commit is contained in:
parent
70d833418b
commit
6288e1169d
11 changed files with 23 additions and 18 deletions
|
@ -250,20 +250,20 @@ fn complete() {
|
|||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn register_dynamic_completion() {
|
||||
common::register_example::<completest_pty::BashRuntimeBuilder>("dynamic", "exhaustive");
|
||||
fn register_dynamic_command() {
|
||||
common::register_example::<completest_pty::BashRuntimeBuilder>("dynamic-command", "exhaustive");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn complete_dynamic() {
|
||||
fn complete_dynamic_command() {
|
||||
if !common::has_command("bash") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::BashRuntimeBuilder>("dynamic", "exhaustive");
|
||||
common::load_runtime::<completest_pty::BashRuntimeBuilder>("dynamic-command", "exhaustive");
|
||||
|
||||
let input = "exhaustive \t\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
|
|
|
@ -331,7 +331,7 @@ pub(crate) fn register_example<R: completest::RuntimeBuilder>(context: &str, nam
|
|||
let mut registration = std::process::Command::new(&bin_path);
|
||||
match context {
|
||||
"static" => registration.args([format!("--generate={shell_name}")]),
|
||||
"dynamic" => registration.args(["complete", shell_name]),
|
||||
"dynamic-command" => registration.args(["complete", shell_name]),
|
||||
_ => unreachable!("unsupported context {}", context),
|
||||
};
|
||||
let registration = registration.output().unwrap();
|
||||
|
|
|
@ -177,20 +177,25 @@ value value
|
|||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn register_dynamic() {
|
||||
common::register_example::<completest_pty::ElvishRuntimeBuilder>("dynamic", "exhaustive");
|
||||
fn register_dynamic_command() {
|
||||
common::register_example::<completest_pty::ElvishRuntimeBuilder>(
|
||||
"dynamic-command",
|
||||
"exhaustive",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn complete_dynamic() {
|
||||
fn complete_dynamic_command() {
|
||||
if !common::has_command("elvish") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::ElvishRuntimeBuilder>("dynamic", "exhaustive");
|
||||
let mut runtime = common::load_runtime::<completest_pty::ElvishRuntimeBuilder>(
|
||||
"dynamic-command",
|
||||
"exhaustive",
|
||||
);
|
||||
|
||||
let input = "exhaustive \t";
|
||||
let expected = snapbox::str![[r#"
|
||||
|
|
|
@ -167,20 +167,20 @@ bash (bash (shell)) fish (fish shell) zsh (zsh shell)"#;
|
|||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn register_dynamic() {
|
||||
common::register_example::<completest_pty::FishRuntimeBuilder>("dynamic", "exhaustive");
|
||||
fn register_dynamic_command() {
|
||||
common::register_example::<completest_pty::FishRuntimeBuilder>("dynamic-command", "exhaustive");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn complete_dynamic() {
|
||||
fn complete_dynamic_command() {
|
||||
if !common::has_command("fish") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::FishRuntimeBuilder>("dynamic", "exhaustive");
|
||||
common::load_runtime::<completest_pty::FishRuntimeBuilder>("dynamic-command", "exhaustive");
|
||||
|
||||
let input = "exhaustive \t\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
|
|
|
@ -165,20 +165,20 @@ pacman action alias value quote hint last --
|
|||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn register_dynamic() {
|
||||
common::register_example::<completest_pty::ZshRuntimeBuilder>("dynamic", "exhaustive");
|
||||
fn register_dynamic_command() {
|
||||
common::register_example::<completest_pty::ZshRuntimeBuilder>("dynamic-command", "exhaustive");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, feature = "unstable-command"))]
|
||||
fn complete_dynamic() {
|
||||
fn complete_dynamic_command() {
|
||||
if !common::has_command("zsh") {
|
||||
return;
|
||||
}
|
||||
|
||||
let term = completest::Term::new();
|
||||
let mut runtime =
|
||||
common::load_runtime::<completest_pty::ZshRuntimeBuilder>("dynamic", "exhaustive");
|
||||
common::load_runtime::<completest_pty::ZshRuntimeBuilder>("dynamic-command", "exhaustive");
|
||||
|
||||
let input = "exhaustive \t\t";
|
||||
let expected = snapbox::str![[r#"
|
||||
|
|
Loading…
Reference in a new issue