Skip to content

Commit 44c69d8

Browse files
committed
test: demonstrate target.triple.rustdocflags doesnt work
1 parent 3fcbf73 commit 44c69d8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/testsuite/rustdocflags.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Tests for setting custom rustdoc flags.
22
33
use cargo_test_support::project;
4+
use cargo_test_support::rustc_host;
5+
use cargo_test_support::rustc_host_env;
46

57
#[cargo_test]
68
fn parses_env() {
@@ -159,3 +161,29 @@ fn not_affected_by_target_rustflags() {
159161
.with_stderr_contains("[RUNNING] `rustdoc [..] --cfg foo[..]`")
160162
.run();
161163
}
164+
165+
#[cargo_test]
166+
fn target_triple_rustdocflags_works() {
167+
let host = rustc_host();
168+
let host_env = rustc_host_env();
169+
let p = project().file("src/lib.rs", "").build();
170+
171+
// target.triple.rustdocflags in env works
172+
p.cargo("doc -v")
173+
.env(
174+
&format!("CARGO_TARGET_{host_env}_RUSTDOCFLAGS"),
175+
"--cfg=foo",
176+
)
177+
.with_stderr_contains("[RUNNING] `rustdoc[..]--cfg[..]foo[..]`")
178+
.run();
179+
180+
// target.triple.rustdocflags in config is not supported.
181+
p.cargo("doc -v")
182+
.arg("--config")
183+
.arg(format!("target.{host}.rustdocflags=['--cfg', 'foo']"))
184+
.with_status(101)
185+
.with_stderr(format!(
186+
"[ERROR] expected a table, but found a array for `target.{host}.rustdocflags` in --config cli option"
187+
))
188+
.run();
189+
}

0 commit comments

Comments
 (0)