fix cargo test --release.

test::verify_check_works was failing in relase mode on my machine.

The problem was it would check for target/debug/rustfmt in release mode instead of
target/release/rustfmt and fail an assert.

This commit fixes it so that cargo check looks for target/debug/rustfmt and
cargo check --release looks for target/release/rustfmt
This commit is contained in:
Matthias Krüger 2018-09-06 02:07:09 +02:00
parent f655671e12
commit e058a3f7e7

View File

@ -944,10 +944,21 @@ fn rustfmt() -> PathBuf {
let mut me = env::current_exe().expect("failed to get current executable"); let mut me = env::current_exe().expect("failed to get current executable");
me.pop(); // chop of the test name me.pop(); // chop of the test name
me.pop(); // chop off `deps` me.pop(); // chop off `deps`
// if we run `cargo test --release` we might only have a release build
if cfg!(release) {
// ../release/
me.pop();
me.push("release");
}
me.push("rustfmt"); me.push("rustfmt");
assert!( assert!(
me.is_file() || me.with_extension("exe").is_file(), me.is_file() || me.with_extension("exe").is_file(),
if cfg!(release) {
"no rustfmt bin, try running `cargo build --release` before testing"
} else {
"no rustfmt bin, try running `cargo build` before testing" "no rustfmt bin, try running `cargo build` before testing"
}
); );
me me
} }