Skip to content

Commit

Permalink
test: target.triple.rustdocflags works for doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo authored and charmitro committed Sep 13, 2024
1 parent 80827d2 commit 9242bd4
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/testsuite/rustdocflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,49 @@ fn target_triple_rustdocflags_works() {
.with_stderr_contains("[RUNNING] `rustdoc[..]--cfg[..]foo[..]`")
.run();
}

#[cargo_test]
fn target_triple_rustdocflags_works_through_cargo_test() {
let host = rustc_host();
let host_env = rustc_host_env();
let p = project()
.file(
"src/lib.rs",
r#"
//! ```
//! assert!(cfg!(foo));
//! ```
"#,
)
.build();

// target.triple.rustdocflags in env works
p.cargo("test --doc -v")
.env(
&format!("CARGO_TARGET_{host_env}_RUSTDOCFLAGS"),
"--cfg=foo",
)
.with_stderr_contains("[RUNNING] `rustdoc[..]--test[..]--cfg[..]foo[..]`")
.with_stdout_contains(
"\
running 1 test
test src/lib.rs - (line 2) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]",
)
.run();

// target.triple.rustdocflags in config works
p.cargo("test --doc -v")
.arg("--config")
.arg(format!("target.{host}.rustdocflags=['--cfg', 'foo']"))
.with_stderr_contains("[RUNNING] `rustdoc[..]--test[..]--cfg[..]foo[..]`")
.with_stdout_contains(
"\
running 1 test
test src/lib.rs - (line 2) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]",
)
.run();
}

0 comments on commit 9242bd4

Please sign in to comment.