Skip to content

Commit

Permalink
Support non-unicode paths for dogfood test
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wright committed Apr 2, 2018
1 parent e91404b commit add4434
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,29 @@ where
path.set_extension("exe");
}

let mut extra_envs = vec![];
if std::env::var("CLIPPY_DOGFOOD").is_ok() {
let target_dir = std::env::var("CARGO_MANIFEST_DIR")
.map(|m| {
std::path::PathBuf::from(m)
.join("target")
.join("dogfood")
.to_string_lossy()
.into_owned()
})
.unwrap_or_else(|_| "clippy_dogfood".to_string());

extra_envs.push(("CARGO_TARGET_DIR", target_dir));
};
let target_dir = std::env::var_os("CLIPPY_DOGFOOD")
.map(|_| {
std::env::var_os("CARGO_MANIFEST_DIR").map_or_else(
|| {
let mut fallback = std::ffi::OsString::new();
fallback.push("clippy_dogfood");
fallback
},
|d| {
std::path::PathBuf::from(d)
.join("target")
.join("dogfood")
.into_os_string()
},
)
})
.map(|p| ("CARGO_TARGET_DIR", p));

let exit_status = std::process::Command::new("cargo")
.args(&args)
.env("RUSTC_WRAPPER", path)
.env("CLIPPY_ARGS", clippy_args)
.envs(extra_envs)
.envs(target_dir)
.spawn()
.expect("could not run cargo")
.wait()
Expand Down

0 comments on commit add4434

Please sign in to comment.