Skip to content

Commit

Permalink
Auto merge of #8094 - Freax13:fix-target, r=ehuss
Browse files Browse the repository at this point in the history
Fix target for doc test cross compilation

- for target paths `Compilation::target` only contains the shortened file name, but we need to pass the full path to rustdoc
  • Loading branch information
bors committed Apr 17, 2020
2 parents 03f11e8 + e5d9b03 commit 6d76d7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit 6d76d7c

Please sign in to comment.