Skip to content

Commit fe6e210

Browse files
committed
Auto merge of #14541 - ehuss:shell_completions-gate, r=<try>
Gate shell_completions tests on availability This changes the shell_completions tests to only run if the corresponding external program is installed. Generally, cargo's tests shouldn't require any external commands to be installed. This also uses the `ignore` attribute for disabling on macos. It is quite confusing when running on macos to see a successful test when it isn't running. This ensures that the test output indicates that it is ignored and the reason. cc `@shannmu`
2 parents 643a025 + fdf4f26 commit fe6e210

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

tests/testsuite/shell_completions.rs

+7-19
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ use cargo_test_support::cargo_test;
44
use completest_pty::Runtime;
55
use snapbox::assert_data_eq;
66

7-
#[cargo_test]
7+
#[cargo_test(requires_bash)]
8+
#[cfg_attr(target_os = "macos", ignore = "bash is not working on macOS")]
89
fn bash() {
9-
// HACK: At least on CI, bash is not working on macOS
10-
if cfg!(target_os = "macos") {
11-
return;
12-
}
13-
1410
let input = "cargo \t\t";
1511
let expected = snapbox::str![
1612
"%
@@ -29,13 +25,9 @@ fn bash() {
2925
assert_data_eq!(actual, expected);
3026
}
3127

32-
#[cargo_test]
28+
#[cargo_test(requires_elvish)]
29+
#[cfg_attr(target_os = "macos", ignore = "elvish is not working on macOS")]
3330
fn elvish() {
34-
// HACK: At least on CI, elvish is not working on macOS
35-
if cfg!(target_os = "macos") {
36-
return;
37-
}
38-
3931
let input = "cargo \t\t";
4032
let expected = snapbox::str![
4133
"% cargo --config
@@ -55,13 +47,9 @@ fn elvish() {
5547
assert_data_eq!(actual, expected);
5648
}
5749

58-
#[cargo_test]
50+
#[cargo_test(requires_fish)]
51+
#[cfg_attr(target_os = "macos", ignore = "fish is not working on macOS")]
5952
fn fish() {
60-
// HACK: At least on CI, fish is not working on macOS
61-
if cfg!(target_os = "macos") {
62-
return;
63-
}
64-
6553
let input = "cargo \t\t";
6654
let expected = snapbox::str![
6755
"% cargo
@@ -125,7 +113,7 @@ yank
125113
assert_data_eq!(actual, expected);
126114
}
127115

128-
#[cargo_test]
116+
#[cargo_test(requires_zsh)]
129117
fn zsh() {
130118
let input = "cargo \t\t";
131119
let expected = snapbox::str![

0 commit comments

Comments
 (0)