Skip to content

Commit

Permalink
test(rustdocflags): shouldn't be affected by rustflags from target.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo committed Nov 1, 2022
1 parent da20496 commit f8d1b30
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/testsuite/rustdocflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit f8d1b30

Please sign in to comment.