1
1
//! Tests for cargo's help output.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_test_support:: registry:: Package ;
4
+ use cargo_test_support:: str;
6
5
use cargo_test_support:: { basic_manifest, cargo_exe, cargo_process, paths, process, project} ;
7
6
use std:: fs;
8
7
use std:: path:: Path ;
@@ -16,11 +15,6 @@ fn help() {
16
15
cargo_process ( "help build" ) . run ( ) ;
17
16
cargo_process ( "build -h" ) . run ( ) ;
18
17
cargo_process ( "help help" ) . run ( ) ;
19
- // Ensure that help output goes to stdout, not stderr.
20
- cargo_process ( "search --help" ) . with_stderr ( "" ) . run ( ) ;
21
- cargo_process ( "search --help" )
22
- . with_stdout_contains ( "[..] --frozen [..]" )
23
- . run ( ) ;
24
18
}
25
19
26
20
#[ cargo_test]
@@ -41,7 +35,10 @@ fn help_external_subcommand() {
41
35
. publish ( ) ;
42
36
cargo_process ( "install cargo-fake-help" ) . run ( ) ;
43
37
cargo_process ( "help fake-help" )
44
- . with_stdout ( "fancy help output\n " )
38
+ . with_stdout_data ( str![ [ r#"
39
+ fancy help output
40
+
41
+ "# ] ] )
45
42
. run ( ) ;
46
43
}
47
44
@@ -147,8 +144,17 @@ fn help_alias() {
147
144
// The `empty-alias` returns an error.
148
145
cargo_process ( "help empty-alias" )
149
146
. env ( "PATH" , Path :: new ( "" ) )
150
- . with_stderr_contains ( "[..]The subcommand 'empty-alias' wasn't recognized[..]" )
151
- . run_expect_error ( ) ;
147
+ . with_status ( 101 )
148
+ . with_stderr_data ( str![ [ r#"
149
+ [ERROR] no such command: `empty-alias`
150
+
151
+ Did you mean `empty-alias`?
152
+
153
+ View all installed commands with `cargo --list`
154
+ Find a package to install `empty-alias` with `cargo search cargo-empty-alias`
155
+
156
+ "# ] ] )
157
+ . run ( ) ;
152
158
153
159
// Because `simple-alias` aliases a subcommand with no arguments, help shows the manpage.
154
160
help_with_man_and_path ( "" , "simple-alias" , "build" , Path :: new ( "" ) ) ;
@@ -157,14 +163,3 @@ fn help_alias() {
157
163
let out = help_with_stdout_and_path ( "complex-alias" , Path :: new ( "" ) ) ;
158
164
assert_eq ! ( out, "`complex-alias` is aliased to `build --release`\n " ) ;
159
165
}
160
-
161
- #[ cargo_test]
162
- fn alias_z_flag_help ( ) {
163
- for cmd in [ "build" , "run" , "check" , "test" , "b" , "r" , "c" , "t" ] {
164
- cargo_process ( & format ! ( "{cmd} -Z help" ) )
165
- . with_stdout_contains (
166
- " -Z allow-features[..] Allow *only* the listed unstable features" ,
167
- )
168
- . run ( ) ;
169
- }
170
- }
0 commit comments