diff options
Diffstat (limited to 'alacritty/src/cli.rs')
-rw-r--r-- | alacritty/src/cli.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs index ce0563ff..d939aff5 100644 --- a/alacritty/src/cli.rs +++ b/alacritty/src/cli.rs @@ -246,6 +246,13 @@ pub enum SocketMessage { mod tests { use super::*; + #[cfg(target_os = "linux")] + use std::fs::File; + #[cfg(target_os = "linux")] + use std::io::Read; + + #[cfg(target_os = "linux")] + use clap::Shell; use serde_yaml::mapping::Mapping; #[test] @@ -334,4 +341,32 @@ mod tests { let class = parse_class("one,two,three"); assert!(class.is_err()); } + + #[cfg(target_os = "linux")] + #[test] + fn completions() { + let mut clap = Options::clap(); + + for (shell, file) in &[ + (Shell::Bash, "alacritty.bash"), + (Shell::Fish, "alacritty.fish"), + (Shell::Zsh, "_alacritty"), + ] { + let mut generated = Vec::new(); + clap.gen_completions_to("alacritty", *shell, &mut generated); + let generated = String::from_utf8_lossy(&generated); + + let mut completion = String::new(); + let mut file = File::open(format!("../extra/completions/{}", file)).unwrap(); + file.read_to_string(&mut completion).unwrap(); + + assert_eq!(generated, completion); + } + + // NOTE: Use this to generate new completions. + // + // clap.gen_completions("alacritty", Shell::Bash, "../extra/completions/"); + // clap.gen_completions("alacritty", Shell::Fish, "../extra/completions/"); + // clap.gen_completions("alacritty", Shell::Zsh, "../extra/completions/"); + } } |