Skip to content

Fix rustfmt tests in the Rust repo #2685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
extern crate assert_cli;

use std::collections::{HashMap, HashSet};
use std::env;
use std::fs;
use std::io::{self, BufRead, BufReader, Read};
use std::iter::{Enumerate, Peekable};
Expand Down Expand Up @@ -892,14 +893,19 @@ impl Drop for TempFile {
}
}

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`
me.push("rustfmt");
return me;
}

#[test]
fn verify_check_works() {
let temp_file = make_temp_file("temp_check.rs");
assert_cli::Assert::command(&[
"cargo",
"run",
"--bin=rustfmt",
"--",
rustfmt().to_str().unwrap(),
"--write-mode=check",
temp_file.path.to_str().unwrap(),
]).succeeds()
Expand All @@ -910,10 +916,7 @@ fn verify_check_works() {
fn verify_diff_works() {
let temp_file = make_temp_file("temp_diff.rs");
assert_cli::Assert::command(&[
"cargo",
"run",
"--bin=rustfmt",
"--",
rustfmt().to_str().unwrap(),
"--write-mode=diff",
temp_file.path.to_str().unwrap(),
]).succeeds()
Expand Down