Skip to content

Commit 60a61d4

Browse files
committed
add tests for doctests with cross compilation
1 parent ecffdcc commit 60a61d4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/testsuite/cross_compile.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,42 @@ 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+
.with_stderr(&format!(
464+
"\
465+
[COMPILING] foo v0.0.1 ([CWD])
466+
[RUNNING] `rustc --crate-name foo [..]--test[..]
467+
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
468+
[RUNNING] `[CWD]/target/{triple}/debug/deps/foo-[..][EXE]`
469+
[DOCTEST] foo
470+
",
471+
triple = target
472+
))
473+
.run();
474+
}
475+
440476
#[cargo_test]
441477
fn simple_cargo_run() {
442478
if !cross_compile::can_run_on_host() {

0 commit comments

Comments
 (0)