Skip to content

Commit add4434

Browse files
author
Michael Wright
committed
Support non-unicode paths for dogfood test
1 parent e91404b commit add4434

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/main.rs

+18-15
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,29 @@ where
7878
path.set_extension("exe");
7979
}
8080

81-
let mut extra_envs = vec![];
82-
if std::env::var("CLIPPY_DOGFOOD").is_ok() {
83-
let target_dir = std::env::var("CARGO_MANIFEST_DIR")
84-
.map(|m| {
85-
std::path::PathBuf::from(m)
86-
.join("target")
87-
.join("dogfood")
88-
.to_string_lossy()
89-
.into_owned()
90-
})
91-
.unwrap_or_else(|_| "clippy_dogfood".to_string());
92-
93-
extra_envs.push(("CARGO_TARGET_DIR", target_dir));
94-
};
81+
let target_dir = std::env::var_os("CLIPPY_DOGFOOD")
82+
.map(|_| {
83+
std::env::var_os("CARGO_MANIFEST_DIR").map_or_else(
84+
|| {
85+
let mut fallback = std::ffi::OsString::new();
86+
fallback.push("clippy_dogfood");
87+
fallback
88+
},
89+
|d| {
90+
std::path::PathBuf::from(d)
91+
.join("target")
92+
.join("dogfood")
93+
.into_os_string()
94+
},
95+
)
96+
})
97+
.map(|p| ("CARGO_TARGET_DIR", p));
9598

9699
let exit_status = std::process::Command::new("cargo")
97100
.args(&args)
98101
.env("RUSTC_WRAPPER", path)
99102
.env("CLIPPY_ARGS", clippy_args)
100-
.envs(extra_envs)
103+
.envs(target_dir)
101104
.spawn()
102105
.expect("could not run cargo")
103106
.wait()

0 commit comments

Comments
 (0)