Skip to content

Commit

Permalink
Combine target env tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Feb 14, 2021
1 parent 4234077 commit 0564466
Showing 1 changed file with 9 additions and 30 deletions.
39 changes: 9 additions & 30 deletions tests/testsuite/tool_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
}
}

Expand Down

0 comments on commit 0564466

Please sign in to comment.