Skip to content

Commit 3b3758c

Browse files
epageytmimi
authored andcommitted
test: Don't make assumptions about the build-dir layout
1 parent 232b448 commit 3b3758c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tests/rustfmt/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ use rustfmt_config_proc_macro::{nightly_only_test, rustfmt_only_ci_test};
99

1010
/// Run the rustfmt executable and return its output.
1111
fn rustfmt(args: &[&str]) -> (String, String) {
12-
let mut bin_dir = env::current_exe().unwrap();
13-
bin_dir.pop(); // chop off test exe name
14-
if bin_dir.ends_with("deps") {
15-
bin_dir.pop();
16-
}
17-
let cmd = bin_dir.join(format!("rustfmt{}", env::consts::EXE_SUFFIX));
12+
let cmd = env!("CARGO_BIN_EXE_rustfmt");
13+
let bin_dir = Path::new(cmd).parent().unwrap();
1814

1915
// Ensure the rustfmt binary runs from the local target dir.
2016
let path = env::var_os("PATH").unwrap_or_default();
2117
let mut paths = env::split_paths(&path).collect::<Vec<_>>();
22-
paths.insert(0, bin_dir);
18+
paths.insert(0, bin_dir.to_owned());
2319
let new_path = env::join_paths(paths).unwrap();
2420

2521
match Command::new(&cmd).args(args).env("PATH", new_path).output() {

0 commit comments

Comments
 (0)