Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix target for doc test cross compilation #8094

Merged
merged 10 commits into from
Apr 17, 2020
7 changes: 5 additions & 2 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ffi::OsString;

use crate::core::compiler::{Compilation, Doctest};
use crate::core::compiler::{Compilation, CompileKind, Doctest};
use crate::core::shell::Verbosity;
use crate::core::Workspace;
use crate::ops;
Expand Down Expand Up @@ -163,7 +163,10 @@ fn run_doc_tests(
.arg(&target.crate_name());

if doctest_xcompile {
p.arg("--target").arg(&compilation.target);
if let CompileKind::Target(target) = options.compile_opts.build_config.requested_kind {
// use `rustc_target()` to properly handle JSON target paths
p.arg("--target").arg(target.rustc_target());
}
p.arg("-Zunstable-options");
p.arg("--enable-per-target-ignores");
}
Expand Down
6 changes: 6 additions & 0 deletions tests/testsuite/custom_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ fn custom_target_minimal() {
p.cargo("build --lib --target custom-target.json -v").run();
p.cargo("build --lib --target src/../custom-target.json -v")
.run();

// Ensure that the correct style of flag is passed to --target with doc tests.
p.cargo("test --doc --target src/../custom-target.json -v -Zdoctest-xcompile")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[RUNNING] `rustdoc [..]--target [..]foo/custom-target.json[..]")
.run();
}

#[cargo_test]
Expand Down