mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
Adapt implementation with reviewer suggestions and requested changes
This commit is contained in:
parent
6ea8abc805
commit
6af31941f3
|
@ -213,15 +213,14 @@ impl Config {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let mut upper_case_env: HashMap<String, String> = HashMap::new();
|
||||
|
||||
if !cfg!(windows) {
|
||||
upper_case_env = env
|
||||
.clone()
|
||||
let upper_case_env = if cfg!(windows) {
|
||||
HashMap::new()
|
||||
} else {
|
||||
env.clone()
|
||||
.into_iter()
|
||||
.map(|(k, _)| (k.to_uppercase().replace("-", "_"), k))
|
||||
.collect();
|
||||
}
|
||||
.collect()
|
||||
};
|
||||
|
||||
let cache_rustc_info = match env.get("CARGO_CACHE_RUSTC_INFO") {
|
||||
Some(cache) => cache != "0",
|
||||
|
@ -568,13 +567,16 @@ impl Config {
|
|||
|
||||
fn check_environment_key_case_mismatch(&self, key: &ConfigKey) {
|
||||
if cfg!(windows) {
|
||||
// In the case of windows the check for case mismatch in keys can be skipped
|
||||
// as windows already converts its environment keys into the desired format.
|
||||
return;
|
||||
}
|
||||
|
||||
match self.upper_case_env.get(key.as_env_key()) {
|
||||
Some(env_key) => {
|
||||
let _ = self.shell().warn(format!(
|
||||
"Variables in environment require uppercase,
|
||||
but given variable: {}, contains lowercase or dash.",
|
||||
"Environment variables require uppercase letters, \
|
||||
but the variable: `{}` contains lowercase letters or dashes.",
|
||||
env_key
|
||||
));
|
||||
}
|
||||
|
|
|
@ -368,14 +368,32 @@ fn target_in_environment_contains_lower_case() {
|
|||
.env(target_key, "nonexistent-linker")
|
||||
.with_status(101)
|
||||
.with_stderr_contains(format!(
|
||||
"warning: Variables in environment require uppercase,
|
||||
but given variable: {}, contains lowercase or dash.",
|
||||
"warning: Environment variables require uppercase letters, \
|
||||
but the variable: `{}` contains lowercase letters or dashes.",
|
||||
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")
|
||||
.without_status()
|
||||
.run();
|
||||
}
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn cfg_ignored_fields() {
|
||||
// Test for some ignored fields in [target.'cfg()'] tables.
|
||||
|
|
Loading…
Reference in a new issue