File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
crates/cargo-test-support/src Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -803,6 +803,15 @@ impl Execs {
803
803
}
804
804
}
805
805
806
+ #[ track_caller]
807
+ pub fn run_expect_error ( & mut self ) {
808
+ self . ran = true ;
809
+ let p = ( & self . process_builder ) . clone ( ) . unwrap ( ) ;
810
+ if self . match_process ( & p) . is_ok ( ) {
811
+ panic ! ( "test was expected to fail, but succeeded running {}" , p) ;
812
+ }
813
+ }
814
+
806
815
/// Runs the process, checks the expected output, and returns the first
807
816
/// JSON object on stdout.
808
817
#[ track_caller]
Original file line number Diff line number Diff line change @@ -55,7 +55,11 @@ fn try_help(config: &Config) -> CargoResult<bool> {
55
55
return Ok ( true ) ;
56
56
}
57
57
// Otherwise, resolve the alias into its subcommand.
58
- Some ( argv) => argv[ 0 ] . clone ( ) ,
58
+ Some ( argv) => {
59
+ // An alias with an empty argv can be created via `"empty-alias" = ""`.
60
+ let first = argv. get ( 0 ) . map ( String :: as_str) . unwrap_or ( subcommand) ;
61
+ first. to_string ( )
62
+ }
59
63
None => subcommand. to_string ( ) ,
60
64
} ;
61
65
Original file line number Diff line number Diff line change @@ -146,12 +146,19 @@ fn help_alias() {
146
146
config,
147
147
r#"
148
148
[alias]
149
- simple-alias = ["build"]
149
+ empty-alias = ""
150
+ simple-alias = "build"
150
151
complex-alias = ["build", "--release"]
151
152
"# ,
152
153
)
153
154
. unwrap ( ) ;
154
155
156
+ // The `empty-alias` returns an error.
157
+ cargo_process ( "help empty-alias" )
158
+ . env ( "PATH" , Path :: new ( "" ) )
159
+ . with_stderr_contains ( "[..]The subcommand 'empty-alias' wasn't recognized[..]" )
160
+ . run_expect_error ( ) ;
161
+
155
162
// Because `simple-alias` aliases a subcommand with no arguments, help shows the manpage.
156
163
help_with_man_and_path ( "" , "simple-alias" , "build" , Path :: new ( "" ) ) ;
157
164
You can’t perform that action at this time.
0 commit comments