Skip to content

Commit 00dd4b7

Browse files
committed
Clarify third party subcommand failure error message
Fixes #2378
1 parent c91bf61 commit 00dd4b7

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/bin/cargo.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fs;
1111
use std::path::PathBuf;
1212

1313
use cargo::execute_main_without_stdin;
14-
use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult};
14+
use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult, ChainError};
1515

1616
#[derive(RustcDecodable)]
1717
pub struct Flags {
@@ -205,7 +205,9 @@ fn execute_subcommand(config: &Config,
205205
}))
206206
}
207207
};
208-
try!(util::process(&command).args(&args[1..]).exec());
208+
try!(util::process(&command).args(&args[1..]).exec().chain_error(|| {
209+
human(format!("third party subcommand `{}` exited unsuccessfully", command_exe))
210+
}));
209211
Ok(())
210212
}
211213

tests/test_cargo_install.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,3 +568,25 @@ be sure to add `[..]` to your PATH to be able to run the installed binaries
568568
assert!(p.release_bin("foo").c_exists());
569569
assert_that(cargo_home(), has_installed_exe("foo"));
570570
});
571+
572+
test!(reports_unsuccessful_subcommand_result {
573+
Package::new("cargo-fail", "1.0.0")
574+
.file("src/main.rs", r#"
575+
fn main() {
576+
panic!();
577+
}
578+
"#)
579+
.publish();
580+
assert_that(cargo_process("install").arg("cargo-fail"),
581+
execs().with_status(0));
582+
assert_that(cargo_process("--list"),
583+
execs().with_status(0).with_stdout_contains(" fail\n"));
584+
assert_that(cargo_process("fail"),
585+
execs().with_status(101).with_stderr_contains("\
586+
thread '<main>' panicked at 'explicit panic', [..]
587+
").with_stderr_contains("\
588+
third party subcommand `cargo-fail[..]` exited unsuccessfully
589+
590+
To learn more, run the command again with --verbose.
591+
"));
592+
});

0 commit comments

Comments
 (0)