Skip to content

Commit

Permalink
nonzero exit code if some crates didn't install
Browse files Browse the repository at this point in the history
  • Loading branch information
durka committed Jul 25, 2017
1 parent 1c7c88a commit ce2d69d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ pub fn install(root: Option<&str>,
let root = resolve_root(root, opts.config)?;
let map = SourceConfigMap::new(opts.config)?;

let installed_anything = if krates.len() <= 1 {
let (installed_anything, scheduled_error) = if krates.len() <= 1 {
install_one(root.clone(), map, krates.into_iter().next(), source_id, vers, opts,
force, true)?;
true
(true, false)
} else {
let mut succeeded = vec![];
let mut failed = vec![];
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn install(root: Option<&str>,
opts.config.shell().status("\nSummary:", summary.join(" "))?;
}

!succeeded.is_empty()
(!succeeded.is_empty(), !failed.is_empty())
};

if installed_anything {
Expand All @@ -114,6 +114,10 @@ pub fn install(root: Option<&str>,
dst.display()))?;
}

if scheduled_error {
bail!("some crates failed to install");
}

Ok(())
}

Expand Down
3 changes: 2 additions & 1 deletion tests/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn multiple_pkgs() {
pkg("bar", "0.0.2");

assert_that(cargo_process("install").args(&["foo", "bar", "baz"]),
execs().with_status(0).with_stderr(&format!("\
execs().with_status(101).with_stderr(&format!("\
[UPDATING] registry `[..]`
[DOWNLOADING] foo v0.0.1 (registry file://[..])
[INSTALLING] foo v0.0.1
Expand All @@ -76,6 +76,7 @@ error: could not find `baz` in `registry [..]`
Summary: Successfully installed foo, bar! Failed to install baz (see error(s) above).
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
error: some crates failed to install
",
home = cargo_home().display())));
assert_that(cargo_home(), has_installed_exe("foo"));
Expand Down

0 comments on commit ce2d69d

Please sign in to comment.