test(rustdocflags): shouldn't be affected by rustflags from target.cfg

This commit is contained in:
Weihang Lo 2022-11-01 14:56:20 +00:00
parent da204963d6
commit f8d1b30ad3
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -122,3 +122,35 @@ fn whitespace() {
let contents = p.read_file("target/doc/foo/index.html");
assert!(contents.contains(SPACED_VERSION));
}
#[cargo_test]
fn not_affected_by_target_rustflags() {
let cfg = if cfg!(windows) { "windows" } else { "unix" };
let p = project()
.file("src/lib.rs", "")
.file(
".cargo/config",
&format!(
r#"
[target.'cfg({cfg})']
rustflags = ["-D", "missing-docs"]
[build]
rustdocflags = ["--cfg", "foo"]
"#,
),
)
.build();
// `cargo build` should fail due to missing docs.
p.cargo("build -v")
.with_status(101)
.with_stderr_contains("[RUNNING] `rustc [..] -D missing-docs[..]`")
.run();
// This is wrong behaviour. `cargo doc` shouldn't fail.
p.cargo("doc -v")
.with_status(101)
.with_stderr_contains("[RUNNING] `rustdoc [..] -D missing-docs[..]`")
.run();
}