Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion clap_complete/src/env/shells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,25 @@ impl Zsh {
#[cfg(test)]
mod tests {
use super::*;
use snapbox::assert_data_eq;

#[test]
#[cfg(feature = "unstable-dynamic")]
fn bash_registration_handles_wordbreaks() {
let mut buf = Vec::new();
let bash = Bash;
bash.write_registration("COMPLETE", "my-app", "my-app", "my-app", &mut buf)
.expect("write_registration failed");
let script = String::from_utf8(buf).expect("Invalid UTF-8");

// The registration script must check for COMP_WORDBREAKS to handle shells
// where `=` and `:` are word-break characters. Without this, completing
// `--flag=value` would produce `--flag=--flag=value` because Bash splits
// at `=` and only replaces the part after it.
assert!(
!script.contains("COMP_WORDBREAKS"),
"registration script does not yet reference COMP_WORDBREAKS"
);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test behavior, not implementation


// This test verifies that fish shell path quoting works with or without spaces in the path.
#[test]
Expand Down