Skip to content

Commit bd902fb

Browse files
committed
test: add smoke tests for shell completions
1 parent 75f3292 commit bd902fb

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/command_completions_test.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
use assert_cmd::Command;
2+
use predicates::prelude::*;
3+
4+
fn test_shell_completion(shell: &str, expected_patterns: &[&str]) {
5+
let depot_dir = tempfile::Builder::new()
6+
.prefix("juliauptest")
7+
.tempdir()
8+
.unwrap();
9+
10+
let mut cmd = Command::cargo_bin("juliaup")
11+
.unwrap()
12+
.arg("completions")
13+
.arg(shell)
14+
.env("JULIA_DEPOT_PATH", depot_dir.path())
15+
.env("JULIAUP_DEPOT_PATH", depot_dir.path())
16+
.assert()
17+
.success();
18+
19+
for pattern in expected_patterns {
20+
cmd = cmd.stdout(predicate::str::contains(*pattern));
21+
}
22+
}
23+
24+
#[test]
25+
fn completions_bash() {
26+
test_shell_completion("bash", &["_juliaup()", "complete -F _juliaup"]);
27+
}
28+
29+
#[test]
30+
fn completions_zsh() {
31+
test_shell_completion("zsh", &["#compdef juliaup", "_juliaup()"]);
32+
}
33+
34+
#[test]
35+
fn completions_fish() {
36+
test_shell_completion("fish", &["complete -c juliaup", "-n \"__fish"]);
37+
}
38+
39+
#[test]
40+
fn completions_powershell() {
41+
test_shell_completion("power-shell", &["Register-ArgumentCompleter", "juliaup"]);
42+
}
43+
44+
#[test]
45+
fn completions_elvish() {
46+
test_shell_completion("elvish", &["edit:completion:arg-completer", "juliaup"]);
47+
}
48+
49+
#[test]
50+
fn completions_nushell() {
51+
test_shell_completion(
52+
"nushell",
53+
&["module completions", "export extern juliaup", "export use completions"],
54+
);
55+
}

0 commit comments

Comments
 (0)