mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 03:32:39 +00:00
Add a test for invalid subcommand displayed on error.
This commit is contained in:
parent
579fa32336
commit
79858995b3
|
@ -211,7 +211,7 @@ fn execute_subcommand(config: &Config,
|
|||
return Err(human(match find_closest(config, cmd) {
|
||||
Some(closest) => format!("no such subcommand: `{}`\n\n\t\
|
||||
Did you mean `{}`?\n", cmd, closest),
|
||||
None => "no such subcommand".to_string()
|
||||
None => format!("no such subcommand: `{}`", cmd)
|
||||
}).into())
|
||||
}
|
||||
};
|
||||
|
|
|
@ -105,7 +105,7 @@ fn find_closest_biuld_to_build() {
|
|||
|
||||
assert_that(pr,
|
||||
execs().with_status(101)
|
||||
.with_stderr("[ERROR] no such subcommand
|
||||
.with_stderr("[ERROR] no such subcommand: `biuld`
|
||||
|
||||
<tab>Did you mean `build`?
|
||||
|
||||
|
@ -121,7 +121,18 @@ fn find_closest_dont_correct_nonsense() {
|
|||
|
||||
assert_that(pr,
|
||||
execs().with_status(101)
|
||||
.with_stderr("[ERROR] no such subcommand
|
||||
.with_stderr("[ERROR] no such subcommand: `there-is-no-way-that-there-is-a-command-close-to-this`
|
||||
"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn displays_subcommand_on_error() {
|
||||
let mut pr = cargo_process();
|
||||
pr.arg("invalid-command");
|
||||
|
||||
assert_that(pr,
|
||||
execs().with_status(101)
|
||||
.with_stderr("[ERROR] no such subcommand: `invalid-command`
|
||||
"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue