-> CargoResult<(Test, Vec<ProcessError>)> {
let mut errors = Vec::new();
let config = options.compile_opts.config;
+ let host_deps = find_host_deps(options, compilation);
// We don't build/rust doctests if target != host
if config.rustc()?.host != compilation.target {
p.arg("--test").arg(lib)
.arg("--crate-name").arg(&crate_name);
+ p.arg("-L").arg(&host_deps);
+
for &rust_dep in &[&compilation.deps_output] {
let mut arg = OsString::from("dependency=");
arg.push(rust_dep);
}
Ok((Test::Doc, errors))
}
+
+fn find_host_deps(options: &TestOptions, compilation: &Compilation) -> OsString {
+ let build_type = if options.compile_opts.release { "release" } else { "debug" };
+ let mut dir = compilation.root_output.clone();
+
+ // first pop off the build_type
+ dir.pop();
+ // if we see the target next, pop it off
+ let target: &OsStr = compilation.target.as_ref();
+ if dir.file_name().unwrap() == target {
+ dir.pop();
+ }
+ // push the build_type back on
+ dir.push(build_type);
+ // and we are looking for the deps directory
+ dir.push("deps");
+
+ let mut host_deps = OsString::from("dependency=");
+ host_deps.push(dir);
+ host_deps
+}
use std::io::prelude::*;
use std::str;
-use cargotest::{sleep_ms, is_nightly};
+use cargotest::{sleep_ms, is_nightly, rustc_host};
use cargotest::support::{project, execs, basic_bin_manifest, basic_lib_manifest, cargo_exe};
use cargotest::support::paths::CargoPathExt;
use cargotest::support::registry::Package;
assert_that(p.cargo("test").arg("--package").arg("testless"),
execs().with_status(0));
}
+
+#[test]
+fn find_dependency_of_proc_macro_dependency_with_target() {
+ let workspace = project("workspace")
+ .file("Cargo.toml", r#"
+ [workspace]
+ members = ["root", "proc_macro_dep"]
+ "#)
+ .file("root/Cargo.toml", r#"
+ [project]
+ name = "root"
+ version = "0.1.0"
+ authors = []
+
+ [dependencies]
+ proc_macro_dep = { path = "../proc_macro_dep" }
+ "#)
+ .file("root/src/lib.rs", r#"
+ #[macro_use]
+ extern crate proc_macro_dep;
+
+ #[derive(Noop)]
+ pub struct X;
+ "#)
+ .file("proc_macro_dep/Cargo.toml", r#"
+ [project]
+ name = "proc_macro_dep"
+ version = "0.1.0"
+ authors = []
+
+ [lib]
+ proc-macro = true
+
+ [dependencies]
+ base64 = "^0.6"
+ "#)
+ .file("proc_macro_dep/src/lib.rs", r#"
+ extern crate base64;
+ extern crate proc_macro;
+ use proc_macro::TokenStream;
+
+ #[proc_macro_derive(Noop)]
+ pub fn noop(_input: TokenStream) -> TokenStream {
+ "".parse().unwrap()
+ }
+ "#);
+ workspace.build();
+ assert_that(workspace.cargo("test").arg("--all").arg("--target").arg(rustc_host()),
+ execs().with_status(0));
+}