Skip to content

Commit

Permalink
Auto merge of #5447 - ehuss:ws-error-message, r=alexcrichton
Browse files Browse the repository at this point in the history
Better error message for `cargo rustc` in a workspace.

Fixes #5371
  • Loading branch information
bors committed May 1, 2018
2 parents f2abbe8 + 037a879 commit 181de52
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,9 @@ impl Packages {
.map(PackageIdSpec::from_package_id)
.filter(|p| opt_out.iter().position(|x| *x == p.name()).is_none())
.collect(),
Packages::Packages(ref packages) if packages.is_empty() => ws.current_opt()
.map(Package::package_id)
.map(PackageIdSpec::from_package_id)
.into_iter()
.collect(),
Packages::Packages(ref packages) if packages.is_empty() => {
vec![PackageIdSpec::from_package_id(ws.current()?.package_id())]
}
Packages::Packages(ref packages) => packages
.iter()
.map(|p| PackageIdSpec::parse(p))
Expand Down
32 changes: 31 additions & 1 deletion tests/testsuite/workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fs::{self, File};
use std::io::{Read, Write};

use cargotest::sleep_ms;
use cargotest::support::{execs, git, project};
use cargotest::support::{basic_lib_manifest, execs, git, project};
use cargotest::support::registry::Package;
use hamcrest::{assert_that, existing_dir, existing_file, is_not};

Expand Down Expand Up @@ -2338,3 +2338,33 @@ fn relative_rustc() {
let file = format!("./foo{}", env::consts::EXE_SUFFIX);
assert_that(p.cargo("build").env("RUSTC", &file), execs().with_status(0));
}


#[test]
fn ws_rustc_err() {
let p = project("ws")
.file(
"Cargo.toml",
r#"
[workspace]
members = ["a"]
"#,
)
.file("a/Cargo.toml", &basic_lib_manifest("a"))
.file("a/src/lib.rs", "")
.build();

assert_that(
p.cargo("rustc"),
execs()
.with_status(101)
.with_stderr("[ERROR] [..]against an actual package[..]"),
);

assert_that(
p.cargo("rustdoc"),
execs()
.with_status(101)
.with_stderr("[ERROR] [..]against an actual package[..]"),
);
}

0 comments on commit 181de52

Please sign in to comment.