Skip to content

Commit 0613244

Browse files
committed
Auto merge of #9203 - ehuss:fix-target_in_environment_contains_lower_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.
2 parents e370c83 + f344f73 commit 0613244

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

tests/testsuite/tool_paths.rs

+21-18
Original file line numberDiff line numberDiff line change
@@ -357,25 +357,28 @@ fn custom_linker_env() {
357357
fn target_in_environment_contains_lower_case() {
358358
let p = project().file("src/main.rs", "fn main() {}").build();
359359

360-
let target_keys = [
361-
"CARGO_TARGET_X86_64_UNKNOWN_LINUX_musl_LINKER",
362-
"CARGO_TARGET_x86_64_unknown_linux_musl_LINKER",
363-
];
364-
365-
for target_key in &target_keys {
366-
let mut execs = p.cargo("build -v --target x86_64-unknown-linux-musl");
367-
execs.env(target_key, "nonexistent-linker").with_status(101);
368-
if cfg!(windows) {
369-
execs.with_stderr_does_not_contain("warning:[..]");
370-
} else {
371-
execs.with_stderr_contains(format!(
372-
"warning: Environment variables are expected to use uppercase letters and underscores, \
373-
the variable `{}` will be ignored and have no effect",
374-
target_key
375-
));
376-
}
377-
execs.run();
360+
let target = rustc_host();
361+
let env_key = format!(
362+
"CARGO_TARGET_{}_LINKER",
363+
target.to_lowercase().replace('-', "_")
364+
);
365+
366+
let mut execs = p.cargo("build -v --target");
367+
execs.arg(target).env(&env_key, "nonexistent-linker");
368+
if cfg!(windows) {
369+
// Windows env keys are case insensitive, so no warning, but it will
370+
// fail due to the missing linker.
371+
execs
372+
.with_stderr_does_not_contain("warning:[..]")
373+
.with_status(101);
374+
} else {
375+
execs.with_stderr_contains(format!(
376+
"warning: Environment variables are expected to use uppercase letters and underscores, \
377+
the variable `{}` will be ignored and have no effect",
378+
env_key
379+
));
378380
}
381+
execs.run();
379382
}
380383

381384
#[cargo_test]

0 commit comments

Comments
 (0)