Skip to content

Commit

Permalink
Test that setting -Zhost-config without -Ztarget-applies-to-host fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshilliard committed May 1, 2021
1 parent 62e2fd4 commit 6dcfe51
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,48 @@ fn custom_build_env_var_rustc_linker_host_target_env() {
}
}

#[cargo_test]
fn custom_build_invalid_host_config_feature_flag() {
let target = rustc_host();
let p = project()
.file(
".cargo/config",
&format!(
r#"
[target.{}]
linker = "/path/to/linker"
"#,
target
),
)
.file(
"build.rs",
r#"
use std::env;
fn main() {
assert!(env::var("RUSTC_LINKER").unwrap().ends_with("/path/to/linker"));
}
"#,
)
.file("src/lib.rs", "")
.build();

// build.rs should fail due to -Zhost-config being set without -Ztarget-applies-to-host
if cargo_test_support::is_nightly() {
p.cargo("build -Z host-config --target")
.arg(&target)
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr_contains(
"\
error: the -Zhost-config flag requires the -Ztarget-applies-to-host flag to be set
",
)
.run();
}
}

#[cargo_test]
fn custom_build_env_var_rustc_linker_host_target_with_bad_host_config() {
let target = rustc_host();
Expand Down

0 comments on commit 6dcfe51

Please sign in to comment.