Skip to content

Commit e77b254

Browse files
committed
Update help::help_alias() to assert the new behavior
1 parent 7084570 commit e77b254

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

tests/testsuite/help.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ fn help_with_man_and_path(
110110
assert_eq!(stdout, contents);
111111
}
112112

113+
fn help_with_stdout_and_path(subcommand: &str, path: &Path) -> String {
114+
let output = process(&cargo_exe())
115+
.arg("help")
116+
.arg(subcommand)
117+
.env("PATH", path)
118+
.exec_with_output()
119+
.unwrap();
120+
assert!(output.status.success());
121+
let stderr = from_utf8(&output.stderr).unwrap();
122+
assert_eq!(stderr, "");
123+
let stdout = from_utf8(&output.stdout).unwrap();
124+
stdout.to_string()
125+
}
126+
113127
#[cargo_test]
114128
fn help_man() {
115129
// Checks that `help command` displays the man page using the given command.
@@ -124,7 +138,8 @@ fn help_man() {
124138
#[cargo_test]
125139
fn help_alias() {
126140
// Check that `help some_alias` will resolve.
127-
help_with_man_and_path("", "b", "build", Path::new(""));
141+
let out = help_with_stdout_and_path("b", Path::new(""));
142+
assert_eq!(out, "'b' is aliased to 'build'\n");
128143

129144
let config = paths::root().join(".cargo/config");
130145
fs::create_dir_all(config.parent().unwrap()).unwrap();
@@ -136,7 +151,8 @@ fn help_alias() {
136151
"#,
137152
)
138153
.unwrap();
139-
help_with_man_and_path("", "my-alias", "build", Path::new(""));
154+
let out = help_with_stdout_and_path("my-alias", Path::new(""));
155+
assert_eq!(out, "'my-alias' is aliased to 'build --release'\n");
140156
}
141157

142158
#[cargo_test]

0 commit comments

Comments
 (0)