Skip to content

Commit

Permalink
test(complete): Specialize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 12, 2024
1 parent 70d8334 commit 6288e11
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 18 deletions.
8 changes: 4 additions & 4 deletions clap_complete/tests/testsuite/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down
2 changes: 1 addition & 1 deletion clap_complete/tests/testsuite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 10 additions & 5 deletions clap_complete/tests/testsuite/elvish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down
8 changes: 4 additions & 4 deletions clap_complete/tests/testsuite/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down
8 changes: 4 additions & 4 deletions clap_complete/tests/testsuite/zsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down

0 comments on commit 6288e11

Please sign in to comment.