Skip to content

Commit 536c539

Browse files
committed
Auto merge of #1522 - alexcrichton:issue-1512, r=huonw
They weren't rlibs so they were left out, but targets which have `plugin = true` should be passed in to `--extern` regardless. Closes #1512
2 parents aff068a + b6609ac commit 536c539

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

src/cargo/ops/cargo_rustc/compilation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::ffi::OsStr;
33
use std::path::PathBuf;
44
use semver::Version;
55

6-
use core::{PackageId, Package};
6+
use core::{PackageId, Package, Target};
77
use util::{self, CargoResult};
88

99
use super::{CommandType, CommandPrototype};
@@ -14,7 +14,7 @@ pub struct Compilation {
1414
///
1515
/// This is currently used for passing --extern flags to rustdoc tests later
1616
/// on.
17-
pub libraries: HashMap<PackageId, Vec<(String, PathBuf)>>,
17+
pub libraries: HashMap<PackageId, Vec<(Target, PathBuf)>>,
1818

1919
/// An array of all tests created during this compilation.
2020
pub tests: Vec<(String, PathBuf)>,

src/cargo/ops/cargo_rustc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn compile_targets<'a, 'b>(targets: &[(&'a Target, &'a Profile)],
142142
} else if target.is_lib() {
143143
let pkgid = pkg.package_id().clone();
144144
cx.compilation.libraries.entry(pkgid).or_insert(Vec::new())
145-
.push((target.crate_name(), dst));
145+
.push((target.clone(), dst));
146146
}
147147
if !target.is_lib() { continue }
148148

@@ -156,7 +156,7 @@ pub fn compile_targets<'a, 'b>(targets: &[(&'a Target, &'a Profile)],
156156

157157
let v = try!(cx.target_filenames(target, profile));
158158
let v = v.into_iter().map(|f| {
159-
(target.crate_name(),
159+
(target.clone(),
160160
cx.out_dir(pkg, Kind::Target, target).join(f))
161161
}).collect::<Vec<_>>();
162162
cx.compilation.libraries.insert(pkgid.clone(), v);

src/cargo/ops/cargo_test.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn run_tests(manifest_path: &Path,
5454
}
5555

5656
for (_, libs) in compile.libraries.iter() {
57-
for &(ref name, ref lib) in libs.iter() {
57+
for &(ref target, ref lib) in libs.iter() {
5858
// Note that we can *only* doctest rlib outputs here. A
5959
// staticlib output cannot be linked by the compiler (it just
6060
// doesn't do that). A dylib output, however, can be linked by
@@ -65,10 +65,11 @@ pub fn run_tests(manifest_path: &Path,
6565
// dynamically as well, causing problems. As a result we only
6666
// pass `--extern` for rlib deps and skip out on all other
6767
// artifacts.
68-
if lib.extension() != Some(OsStr::new("rlib")) {
68+
if lib.extension() != Some(OsStr::new("rlib")) &&
69+
!target.for_host() {
6970
continue
7071
}
71-
let mut arg = OsString::from(name);
72+
let mut arg = OsString::from(target.crate_name());
7273
arg.push("=");
7374
arg.push(lib);
7475
p.arg("--extern").arg(&arg);

tests/test_cargo_compile_plugins.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,34 @@ test!(plugin_integration {
188188
assert_that(p.cargo_process("test"),
189189
execs().with_status(0));
190190
});
191+
192+
test!(doctest_a_plugin {
193+
let p = project("foo")
194+
.file("Cargo.toml", r#"
195+
[package]
196+
name = "foo"
197+
version = "0.0.1"
198+
authors = []
199+
200+
[dependencies]
201+
bar = { path = "bar" }
202+
"#)
203+
.file("src/lib.rs", r#"
204+
#[macro_use]
205+
extern crate bar;
206+
"#)
207+
.file("bar/Cargo.toml", r#"
208+
[package]
209+
name = "bar"
210+
version = "0.0.1"
211+
authors = []
212+
213+
[lib]
214+
name = "bar"
215+
plugin = true
216+
"#)
217+
.file("bar/src/lib.rs", "");
218+
219+
assert_that(p.cargo_process("test").arg("-v"),
220+
execs().with_status(0));
221+
});

0 commit comments

Comments
 (0)