Use exit code 1 for command line parsing errors
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 8 Mar 2018 18:55:12 +0000 (21:55 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 8 Mar 2018 20:31:56 +0000 (23:31 +0300)
Note that while we use 101 in majority of cases, sometimes we use 1 as
well.

tests/testsuite/install.rs
tests/testsuite/metadata.rs
tests/testsuite/run.rs
tests/testsuite/rustc.rs

index a569d8c5a27762c5546c2695d3f16ad462561021..f95c36a052c187ed0c375cfc0984f4310145b663 100644 (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
 "));
 }
 
index 38e04171d478b7395139815f8175ce8034869e2a..296e6f3f0269bf4acbaa3098d7cc969978f25bb7 100644 (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]
index d388ebf512349d4a4d34fb3fb5ac7f164c8072ae..6717b57034d53fc362dd0fe3f5d9860a0006ed49 100644 (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()
index 445341d7b5e1fb3d20db5ba731fecacb67362702..72629f6b306abbe0fec02a430a6d9b1f15723165 100644 (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]