aboutsummaryrefslogtreecommitdiff
path: root/alacritty
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty')
-rw-r--r--alacritty/Cargo.toml3
-rw-r--r--alacritty/src/cli.rs35
2 files changed, 38 insertions, 0 deletions
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index 5d02d19c..82a47a86 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -35,6 +35,9 @@ unicode-width = "0.1"
bitflags = "1"
dirs = "3.0.1"
+[dev-dependencies]
+clap = "2.33.3"
+
[build-dependencies]
gl_generator = "0.14.0"
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/");
+ }
}