11//! Tests for cargo's help output.
22
3- #![ allow( deprecated) ]
4-
53use cargo_test_support:: registry:: Package ;
4+ use cargo_test_support:: str;
65use cargo_test_support:: { basic_manifest, cargo_exe, cargo_process, paths, process, project} ;
76use std:: fs;
87use std:: path:: Path ;
@@ -16,11 +15,6 @@ fn help() {
1615 cargo_process ( "help build" ) . run ( ) ;
1716 cargo_process ( "build -h" ) . run ( ) ;
1817 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 ( ) ;
2418}
2519
2620#[ cargo_test]
@@ -41,7 +35,10 @@ fn help_external_subcommand() {
4135 . publish ( ) ;
4236 cargo_process ( "install cargo-fake-help" ) . run ( ) ;
4337 cargo_process ( "help fake-help" )
44- . with_stdout ( "fancy help output\n " )
38+ . with_stdout_data ( str![ [ r#"
39+ fancy help output
40+
41+ "# ] ] )
4542 . run ( ) ;
4643}
4744
@@ -147,8 +144,17 @@ fn help_alias() {
147144 // The `empty-alias` returns an error.
148145 cargo_process ( "help empty-alias" )
149146 . 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 ( ) ;
152158
153159 // Because `simple-alias` aliases a subcommand with no arguments, help shows the manpage.
154160 help_with_man_and_path ( "" , "simple-alias" , "build" , Path :: new ( "" ) ) ;
@@ -157,14 +163,3 @@ fn help_alias() {
157163 let out = help_with_stdout_and_path ( "complex-alias" , Path :: new ( "" ) ) ;
158164 assert_eq ! ( out, "`complex-alias` is aliased to `build --release`\n " ) ;
159165}
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