Skip to content

Commit e5d9b03

Browse files
committed
add test for doctests with custom target paths
1 parent 4785b64 commit e5d9b03

File tree

2 files changed

+6
-39
lines changed

2 files changed

+6
-39
lines changed

tests/testsuite/cross_compile.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -437,45 +437,6 @@ fn no_cross_doctests() {
437437
.run();
438438
}
439439

440-
#[cargo_test]
441-
fn cross_doctests() {
442-
if cross_compile::disabled() || !cross_compile::can_run_on_host() || !is_nightly() {
443-
return;
444-
}
445-
446-
let p = project()
447-
.file(
448-
"src/lib.rs",
449-
r#"
450-
//! ```
451-
//! extern crate foo;
452-
//! assert!(true);
453-
//! ```
454-
"#,
455-
)
456-
.build();
457-
458-
let target = cross_compile::alternate();
459-
460-
// This tests the library and runs the doc tests.
461-
p.cargo("test -v -Z doctest-xcompile --target")
462-
.arg(&target)
463-
.masquerade_as_nightly_cargo()
464-
.with_stderr(&format!(
465-
"\
466-
[COMPILING] foo v0.0.1 ([CWD])
467-
[RUNNING] `rustc --crate-name foo [..]
468-
[RUNNING] `rustc --crate-name foo [..]--test[..]
469-
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
470-
[RUNNING] `[CWD]/target/{triple}/debug/deps/foo-[..][EXE]`
471-
[DOCTEST] foo
472-
[RUNNING] `rustdoc [..]
473-
",
474-
triple = target
475-
))
476-
.run();
477-
}
478-
479440
#[cargo_test]
480441
fn simple_cargo_run() {
481442
if !cross_compile::can_run_on_host() {

tests/testsuite/custom_target.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ fn custom_target_minimal() {
5151
p.cargo("build --lib --target custom-target.json -v").run();
5252
p.cargo("build --lib --target src/../custom-target.json -v")
5353
.run();
54+
55+
// Ensure that the correct style of flag is passed to --target with doc tests.
56+
p.cargo("test --doc --target src/../custom-target.json -v -Zdoctest-xcompile")
57+
.masquerade_as_nightly_cargo()
58+
.with_stderr_contains("[RUNNING] `rustdoc [..]--target [..]foo/custom-target.json[..]")
59+
.run();
5460
}
5561

5662
#[cargo_test]

0 commit comments

Comments
 (0)