Use exit code 1 for command line parsing errors

Note that while we use 101 in majority of cases, sometimes we use 1 as
well.
This commit is contained in:
Aleksey Kladov 2018-03-08 21:55:12 +03:00
parent 31ea0d93f7
commit 4d3ca92150
4 changed files with 26 additions and 12 deletions

View file

@ -986,14 +986,14 @@ fn version_too() {
}
#[test]
#[ignore]
fn not_both_vers_and_version() {
pkg("foo", "0.1.1");
pkg("foo", "0.1.2");
assert_that(cargo_process("install").arg("foo").arg("--version").arg("0.1.1").arg("--vers").arg("0.1.2"),
execs().with_status(101).with_stderr_contains("\
error: invalid arguments
execs().with_status(1).with_stderr_contains("\
error: The argument '--version <VERSION>' was provided more than once, \
but cannot be used multiple times
"));
}

View file

@ -743,7 +743,6 @@ fn cargo_metadata_no_deps_cwd() {
}
#[test]
#[ignore]
fn cargo_metadata_bad_version() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
@ -753,8 +752,16 @@ fn cargo_metadata_bad_version() {
assert_that(p.cargo("metadata").arg("--no-deps")
.arg("--format-version").arg("2")
.cwd(p.root()),
execs().with_status(101)
.with_stderr("[ERROR] metadata version 2 not supported, only 1 is currently supported"));
execs().with_status(1)
.with_stderr("\
error: '2' isn't a valid value for '--format-version <VERSION>'
<tab>[possible values: 1]
USAGE:
cargo metadata --format-version <VERSION> --no-deps
For more information try --help"));
}
#[test]

View file

@ -743,7 +743,6 @@ fn fail_no_extra_verbose() {
}
#[test]
#[ignore]
fn run_multiple_packages() {
let p = project("foo")
.file("foo/Cargo.toml", r#"
@ -811,7 +810,13 @@ fn run_multiple_packages() {
assert_that(cargo().arg("-p").arg("d1").arg("-p").arg("d2"),
execs()
.with_status(1)
.with_stderr_contains("[ERROR] Invalid arguments."));
.with_stderr("\
error: The argument '--package <SPEC>' was provided more than once, but cannot be used multiple times
USAGE:
cargo run --message-format <FMT> --package <SPEC>
For more information try --help"));
assert_that(cargo().arg("-p").arg("d3"),
execs()

View file

@ -306,7 +306,6 @@ fn build_only_bar_dependency() {
}
#[test]
#[ignore]
fn fail_with_multiple_packages() {
let foo = project("foo")
.file("Cargo.toml", r#"
@ -357,10 +356,13 @@ fn fail_with_multiple_packages() {
assert_that(foo.cargo("rustc").arg("-v").arg("-p").arg("bar")
.arg("-p").arg("baz"),
execs().with_status(1).with_stderr("\
[ERROR] Invalid arguments.
error: The argument '--package <SPEC>' was provided more than once, \
but cannot be used multiple times
Usage:
cargo rustc [options] [--] [<opts>...]"));
USAGE:
cargo rustc --message-format <FMT> --package <SPEC> --verbose
For more information try --help"));
}
#[test]