Merge pull request #2997 from matthiaskrgr/cargo_test_release

fix cargo test --release
This commit is contained in:
Nick Cameron 2018-09-06 17:40:08 +12:00 committed by GitHub
commit 6ada5b51cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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