Skip to content

Commit ae8b752

Browse files
committed
Auto merge of #1705 - alexcrichton:fix-test-non-root-package, r=brson
The previous overhaul of how dependencies among build dependencies were traversed ended up picking the wrong root package when the `-p` argument was specified to commands. This commit fixes this up by making sure the right root package is passed along.
2 parents e26072e + b3e2ac0 commit ae8b752

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/cargo/ops/cargo_rustc/custom_build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ impl BuildOutput {
348348
/// The given set of targets to this function is the initial set of
349349
/// targets/profiles which are being built.
350350
pub fn build_map<'b, 'cfg>(cx: &mut Context<'b, 'cfg>,
351+
pkg: &'b Package,
351352
targets: &[(&Target, &'b Profile)]) {
352353
let mut ret = HashMap::new();
353-
let pkg = cx.get_package(cx.resolve.root());
354354
for &(target, profile) in targets {
355355
build(&mut ret, Kind::Target, pkg, target, profile, cx);
356356
build(&mut ret, Kind::Host, pkg, target, profile, cx);

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn compile_targets<'a, 'cfg: 'a>(targets: &[(&'a Target, &'a Profile)],
117117
let _p = profile::start("preparing build directories");
118118
try!(cx.prepare(pkg, targets));
119119
prepare_init(&mut cx, pkg, &mut queue, &mut HashSet::new());
120-
custom_build::build_map(&mut cx, targets);
120+
custom_build::build_map(&mut cx, pkg, targets);
121121
}
122122

123123
// Build up a list of pending jobs, each of which represent compiling a

tests/test_cargo_compile_custom_build.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fs::{self, File};
33
use std::io::prelude::*;
44

55
use support::{project, execs};
6-
use support::{COMPILING, RUNNING, DOCTEST};
6+
use support::{COMPILING, RUNNING, DOCTEST, FRESH};
77
use support::paths::CargoPathExt;
88
use hamcrest::{assert_that};
99

@@ -1355,4 +1355,17 @@ running 0 tests
13551355
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
13561356
13571357
", compiling = COMPILING, running = RUNNING)));
1358+
1359+
assert_that(p.cargo("test").arg("-v").arg("-pb").arg("--lib"),
1360+
execs().with_status(0).with_stdout(&format!("\
1361+
{compiling} b v0.5.0 ([..]
1362+
{running} `rustc b[..]src[..]lib.rs [..] -L test[..]`
1363+
{fresh} a v0.5.0 ([..]
1364+
{running} `[..]b-[..]`
1365+
1366+
running 0 tests
1367+
1368+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
1369+
1370+
", compiling = COMPILING, running = RUNNING, fresh = FRESH)));
13581371
});

0 commit comments

Comments
 (0)