Skip to content

Commit

Permalink
Auto merge of #9203 - ehuss:fix-target_in_environment_contains_lower_…
Browse files Browse the repository at this point in the history
…case, r=alexcrichton

Fix test target_in_environment_contains_lower_case

This test will fail if you actually have the x86_64-unknown-linux-musl target installed.  Instead of assuming it will fail, this uses the host target instead, which should only fail on windows due to case-insensitive environment keys.
  • Loading branch information
bors committed Feb 24, 2021
2 parents e370c83 + f344f73 commit 0613244
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions tests/testsuite/tool_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,25 +357,28 @@ fn custom_linker_env() {
fn target_in_environment_contains_lower_case() {
let p = project().file("src/main.rs", "fn main() {}").build();

let target_keys = [
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_musl_LINKER",
"CARGO_TARGET_x86_64_unknown_linux_musl_LINKER",
];

for target_key in &target_keys {
let mut execs = p.cargo("build -v --target x86_64-unknown-linux-musl");
execs.env(target_key, "nonexistent-linker").with_status(101);
if cfg!(windows) {
execs.with_stderr_does_not_contain("warning:[..]");
} else {
execs.with_stderr_contains(format!(
"warning: Environment variables are expected to use uppercase letters and underscores, \
the variable `{}` will be ignored and have no effect",
target_key
));
}
execs.run();
let target = rustc_host();
let env_key = format!(
"CARGO_TARGET_{}_LINKER",
target.to_lowercase().replace('-', "_")
);

let mut execs = p.cargo("build -v --target");
execs.arg(target).env(&env_key, "nonexistent-linker");
if cfg!(windows) {
// Windows env keys are case insensitive, so no warning, but it will
// fail due to the missing linker.
execs
.with_stderr_does_not_contain("warning:[..]")
.with_status(101);
} else {
execs.with_stderr_contains(format!(
"warning: Environment variables are expected to use uppercase letters and underscores, \
the variable `{}` will be ignored and have no effect",
env_key
));
}
execs.run();
}

#[cargo_test]
Expand Down

0 comments on commit 0613244

Please sign in to comment.