Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6ada5b5

Browse files
authored
Merge pull request rust-lang#2997 from matthiaskrgr/cargo_test_release
fix cargo test --release
2 parents f655671 + e058a3f commit 6ada5b5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,21 @@ fn rustfmt() -> PathBuf {
944944
let mut me = env::current_exe().expect("failed to get current executable");
945945
me.pop(); // chop of the test name
946946
me.pop(); // chop off `deps`
947+
948+
// if we run `cargo test --release` we might only have a release build
949+
if cfg!(release) {
950+
// ../release/
951+
me.pop();
952+
me.push("release");
953+
}
947954
me.push("rustfmt");
948955
assert!(
949956
me.is_file() || me.with_extension("exe").is_file(),
950-
"no rustfmt bin, try running `cargo build` before testing"
957+
if cfg!(release) {
958+
"no rustfmt bin, try running `cargo build --release` before testing"
959+
} else {
960+
"no rustfmt bin, try running `cargo build` before testing"
961+
}
951962
);
952963
me
953964
}

0 commit comments

Comments
 (0)