Add a test for invalid subcommand displayed on error.

This commit is contained in:
Kaivo Anastetiks 2016-07-05 08:09:11 -04:00
parent 579fa32336
commit 79858995b3
2 changed files with 14 additions and 3 deletions

View file

@ -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())
}
};

View file

@ -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`
"));
}