1
Fork 0

improve tidy to give you file that failed

the current tidy panics give you no idea why it failed
This commit is contained in:
Niko Matsakis 2016-04-16 06:11:18 -04:00
parent 01d2b4ab6b
commit bf624c413f
4 changed files with 9 additions and 4 deletions

View file

@ -35,7 +35,7 @@ pub fn check(path: &Path, bad: &mut bool) {
return
}
let metadata = t!(fs::metadata(&file));
let metadata = t!(fs::metadata(&file), &file);
if metadata.mode() & 0o111 != 0 {
println!("binary checked into source: {}", file.display());
*bad = true;

View file

@ -20,7 +20,7 @@ use std::fs::File;
use std::path::Path;
pub fn check(path: &Path, bad: &mut bool) {
for entry in t!(path.read_dir()).map(|e| t!(e)) {
for entry in t!(path.read_dir(), path).map(|e| t!(e)) {
// Look for `Cargo.toml` with a sibling `src/lib.rs` or `lib.rs`
if entry.file_name().to_str() == Some("Cargo.toml") {
if path.join("src/lib.rs").is_file() {

View file

@ -19,6 +19,11 @@ use std::path::{PathBuf, Path};
use std::env;
macro_rules! t {
($e:expr, $p:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed on {} with {}", stringify!($e), ($p).display(), e),
});
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {}", stringify!($e), e),
@ -63,7 +68,7 @@ fn filter_dirs(path: &Path) -> bool {
fn walk(path: &Path, skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
for entry in t!(fs::read_dir(path)) {
for entry in t!(fs::read_dir(path), path) {
let entry = t!(entry);
let kind = t!(entry.file_type());
let path = entry.path();

View file

@ -52,7 +52,7 @@ pub fn check(path: &Path, bad: &mut bool) {
}
contents.truncate(0);
t!(t!(File::open(file)).read_to_string(&mut contents));
t!(t!(File::open(file), file).read_to_string(&mut contents));
let skip_cr = contents.contains("ignore-tidy-cr");
let skip_tab = contents.contains("ignore-tidy-tab");
let skip_length = contents.contains("ignore-tidy-linelength");