Skip to content

Commit

Permalink
Auto merge of #4624 - sinkuu:workaround_cargo, r=llogiq
Browse files Browse the repository at this point in the history
Workaround cargo issue on appveyor

Use absolute paths for `cargo` and `rustfmt` to workaround rust-lang/cargo#7475.

Appveyor passed on my fork: https://ci.appveyor.com/project/sinkuu/rust-clippy/builds/27870367
  • Loading branch information
bors committed Oct 4, 2019
2 parents 737f0a6 + 248251b commit ad1a8f6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ regex = "1"
lazy_static = "1.0"
shell-escape = "0.1"
walkdir = "2"
# FIXME: remove this once cargo issue #7475 is fixed
home = "0.5"
15 changes: 12 additions & 3 deletions clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ fn cargo_fmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
args.push("--");
args.push("--check");
}
let success = exec(context, "cargo", path, &args)?;
let success = exec(context, &bin_path("cargo"), path, &args)?;

Ok(success)
}

fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
let program = "rustfmt";
let program = bin_path("rustfmt");
let dir = std::env::current_dir()?;
let args = &["+nightly", "--version"];

Expand All @@ -173,7 +173,7 @@ fn rustfmt(context: &FmtContext, path: &Path) -> Result<bool, CliError> {
if context.check {
args.push("--check".as_ref());
}
let success = exec(context, "rustfmt", std::env::current_dir()?, &args)?;
let success = exec(context, &bin_path("rustfmt"), std::env::current_dir()?, &args)?;
if !success {
eprintln!("rustfmt failed on {}", path.display());
}
Expand All @@ -198,3 +198,12 @@ fn project_root() -> Result<PathBuf, CliError> {

Err(CliError::ProjectRootNotFound)
}

// Workaround for https://github.com/rust-lang/cargo/issues/7475.
// FIXME: replace `&bin_path("command")` with `"command"` once the issue is fixed
fn bin_path(bin: &str) -> String {
let mut p = home::cargo_home().unwrap();
p.push("bin");
p.push(bin);
p.display().to_string()
}

0 comments on commit ad1a8f6

Please sign in to comment.