Skip to content

Commit

Permalink
add test for doctests with custom target paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Apr 17, 2020
1 parent 4785b64 commit e5d9b03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 39 deletions.
39 changes: 0 additions & 39 deletions tests/testsuite/cross_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,45 +437,6 @@ fn no_cross_doctests() {
.run();
}

#[cargo_test]
fn cross_doctests() {
if cross_compile::disabled() || !cross_compile::can_run_on_host() || !is_nightly() {
return;
}

let p = project()
.file(
"src/lib.rs",
r#"
//! ```
//! extern crate foo;
//! assert!(true);
//! ```
"#,
)
.build();

let target = cross_compile::alternate();

// This tests the library and runs the doc tests.
p.cargo("test -v -Z doctest-xcompile --target")
.arg(&target)
.masquerade_as_nightly_cargo()
.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] `[CWD]/target/{triple}/debug/deps/foo-[..][EXE]`
[DOCTEST] foo
[RUNNING] `rustdoc [..]
",
triple = target
))
.run();
}

#[cargo_test]
fn simple_cargo_run() {
if !cross_compile::can_run_on_host() {
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 e5d9b03

Please sign in to comment.