Skip to content

Commit a547d19

Browse files
committed
Add test verifying behavior in #10744
1 parent c1fe2bd commit a547d19

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/testsuite/rustflags.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,3 +1587,47 @@ fn host_config_rustflags_with_target() {
15871587
.arg("host.rustflags=[\"--cfg=foo\"]")
15881588
.run();
15891589
}
1590+
1591+
#[cargo_test]
1592+
fn target_applies_to_host_rustflags_works() {
1593+
// Ensures that rustflags are passed to the target when
1594+
// target_applies_to_host=false
1595+
let p = project()
1596+
.file(
1597+
"src/lib.rs",
1598+
r#"#[cfg(feature = "flag")] compile_error!("flag passed");"#,
1599+
)
1600+
.build();
1601+
1602+
// Use RUSTFLAGS to pass an argument that would generate an error
1603+
// but it is ignored.
1604+
p.cargo("check")
1605+
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
1606+
.arg("-Ztarget-applies-to-host")
1607+
.env("CARGO_TARGET_APPLIES_TO_HOST", "false")
1608+
.env("RUSTFLAGS", r#"--cfg feature="flag""#)
1609+
.with_status(0)
1610+
.run();
1611+
}
1612+
1613+
#[cargo_test]
1614+
fn target_applies_to_host_rustdocflags_works() {
1615+
// Ensures that rustflags are passed to the target when
1616+
// target_applies_to_host=false
1617+
let p = project()
1618+
.file(
1619+
"src/lib.rs",
1620+
r#"#[cfg(feature = "flag")] compile_error!("flag passed");"#,
1621+
)
1622+
.build();
1623+
1624+
// Use RUSTFLAGS to pass an argument that would generate an error
1625+
// but it is ignored.
1626+
p.cargo("doc")
1627+
.masquerade_as_nightly_cargo(&["target-applies-to-host"])
1628+
.arg("-Ztarget-applies-to-host")
1629+
.env("CARGO_TARGET_APPLIES_TO_HOST", "false")
1630+
.env("RUSTDOCFLAGS", r#"--cfg feature="flag""#)
1631+
.with_status(0)
1632+
.run();
1633+
}

0 commit comments

Comments
 (0)