Skip to content

Commit f8aed3d

Browse files
authored
Merge pull request #2685 from alexcrichton/fix-tests
Fix rustfmt tests in the Rust repo
2 parents f46f4b5 + a72be17 commit f8aed3d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/test/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
extern crate assert_cli;
1212

1313
use std::collections::{HashMap, HashSet};
14+
use std::env;
1415
use std::fs;
1516
use std::io::{self, BufRead, BufReader, Read};
1617
use std::iter::{Enumerate, Peekable};
@@ -892,14 +893,19 @@ impl Drop for TempFile {
892893
}
893894
}
894895

896+
fn rustfmt() -> PathBuf {
897+
let mut me = env::current_exe().expect("failed to get current executable");
898+
me.pop(); // chop of the test name
899+
me.pop(); // chop off `deps`
900+
me.push("rustfmt");
901+
return me;
902+
}
903+
895904
#[test]
896905
fn verify_check_works() {
897906
let temp_file = make_temp_file("temp_check.rs");
898907
assert_cli::Assert::command(&[
899-
"cargo",
900-
"run",
901-
"--bin=rustfmt",
902-
"--",
908+
rustfmt().to_str().unwrap(),
903909
"--write-mode=check",
904910
temp_file.path.to_str().unwrap(),
905911
]).succeeds()
@@ -910,10 +916,7 @@ fn verify_check_works() {
910916
fn verify_diff_works() {
911917
let temp_file = make_temp_file("temp_diff.rs");
912918
assert_cli::Assert::command(&[
913-
"cargo",
914-
"run",
915-
"--bin=rustfmt",
916-
"--",
919+
rustfmt().to_str().unwrap(),
917920
"--write-mode=diff",
918921
temp_file.path.to_str().unwrap(),
919922
]).succeeds()

0 commit comments

Comments
 (0)