Combine target env tests.

This commit is contained in:
Eric Huss 2021-02-14 11:32:18 -08:00
parent 4234077bc2
commit 0564466f45

View File

@ -354,7 +354,6 @@ fn custom_linker_env() {
}
#[cargo_test]
#[cfg(not(windows))]
fn target_in_environment_contains_lower_case() {
let p = project().file("src/main.rs", "fn main() {}").build();
@ -364,38 +363,18 @@ fn target_in_environment_contains_lower_case() {
];
for target_key in &target_keys {
p.cargo("build -v --target x86_64-unknown-linux-musl")
.env(target_key, "nonexistent-linker")
.with_status(101)
.with_stderr_contains(format!(
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
))
.run();
}
}
#[cargo_test]
#[cfg(windows)]
fn target_in_environment_contains_lower_case_on_windows() {
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 {
p.cargo("build -v --target x86_64-unknown-linux-musl")
.env(target_key, "nonexistent-linker")
.with_status(101)
.with_stderr_does_not_contain(format!(
"warning: Environment variables are expected to use uppercase letters and underscores, \
the variable `{}` will be ignored and have no effect",
target_key
))
.run();
));
}
execs.run();
}
}