Skip to content

Commit

Permalink
Auto merge of #10594 - weihanglo:issue-10560, r=ehuss
Browse files Browse the repository at this point in the history
Pass `--target` to `rustdoc` for `cargo test` if specified with host target.
  • Loading branch information
bors committed May 10, 2022
2 parents 9fa2bba + ba2b250 commit cc9e301
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,12 @@ fn run_doc_tests(
p.arg(unit.target.src_path().path().unwrap());
}

if let CompileKind::Target(target) = unit.kind {
// use `rustc_target()` to properly handle JSON target paths
p.arg("--target").arg(target.rustc_target());
}

if doctest_xcompile {
if let CompileKind::Target(target) = unit.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");
if let Some((runtool, runtool_args)) = compilation.target_runner(unit.kind) {
Expand Down
22 changes: 19 additions & 3 deletions tests/testsuite/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,17 +592,33 @@ fn no_cross_doctests() {

println!("b");
let target = rustc_host();
p.cargo("test --target")
p.cargo("test -v --target")
.arg(&target)
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo [..]
[RUNNING] `rustc --crate-name foo [..]--test[..]
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
[RUNNING] [..] (target/{triple}/debug/deps/foo-[..][EXE])
[RUNNING] `[CWD]/target/{target}/debug/deps/foo-[..][EXE]`
[DOCTEST] foo
[RUNNING] `rustdoc [..]--target {target}[..]`
",
triple = target
))
.with_stdout(
"
running 0 tests
test result: ok. 0 passed[..]
running 1 test
test src/lib.rs - (line 2) ... ok
test result: ok. 1 passed[..]
",
)
.run();

println!("c");
Expand Down

0 comments on commit cc9e301

Please sign in to comment.