Skip to content

Commit

Permalink
Add test verifying behavior in rust-lang#10744
Browse files Browse the repository at this point in the history
  • Loading branch information
gmorenz committed Jul 4, 2024
1 parent c1fe2bd commit a547d19
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/testsuite/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,3 +1587,47 @@ fn host_config_rustflags_with_target() {
.arg("host.rustflags=[\"--cfg=foo\"]")
.run();
}

#[cargo_test]
fn target_applies_to_host_rustflags_works() {
// Ensures that rustflags are passed to the target when
// target_applies_to_host=false
let p = project()
.file(
"src/lib.rs",
r#"#[cfg(feature = "flag")] compile_error!("flag passed");"#,
)
.build();

// Use RUSTFLAGS to pass an argument that would generate an error
// but it is ignored.
p.cargo("check")
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
.arg("-Ztarget-applies-to-host")
.env("CARGO_TARGET_APPLIES_TO_HOST", "false")
.env("RUSTFLAGS", r#"--cfg feature="flag""#)
.with_status(0)
.run();
}

#[cargo_test]
fn target_applies_to_host_rustdocflags_works() {
// Ensures that rustflags are passed to the target when
// target_applies_to_host=false
let p = project()
.file(
"src/lib.rs",
r#"#[cfg(feature = "flag")] compile_error!("flag passed");"#,
)
.build();

// Use RUSTFLAGS to pass an argument that would generate an error
// but it is ignored.
p.cargo("doc")
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
.arg("-Ztarget-applies-to-host")
.env("CARGO_TARGET_APPLIES_TO_HOST", "false")
.env("RUSTDOCFLAGS", r#"--cfg feature="flag""#)
.with_status(0)
.run();
}

0 comments on commit a547d19

Please sign in to comment.