improve tidy to give you file that failed
the current tidy panics give you no idea why it failed
This commit is contained in:
parent
01d2b4ab6b
commit
bf624c413f
4 changed files with 9 additions and 4 deletions
|
@ -35,7 +35,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let metadata = t!(fs::metadata(&file));
|
let metadata = t!(fs::metadata(&file), &file);
|
||||||
if metadata.mode() & 0o111 != 0 {
|
if metadata.mode() & 0o111 != 0 {
|
||||||
println!("binary checked into source: {}", file.display());
|
println!("binary checked into source: {}", file.display());
|
||||||
*bad = true;
|
*bad = true;
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn check(path: &Path, bad: &mut bool) {
|
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`
|
// Look for `Cargo.toml` with a sibling `src/lib.rs` or `lib.rs`
|
||||||
if entry.file_name().to_str() == Some("Cargo.toml") {
|
if entry.file_name().to_str() == Some("Cargo.toml") {
|
||||||
if path.join("src/lib.rs").is_file() {
|
if path.join("src/lib.rs").is_file() {
|
||||||
|
|
|
@ -19,6 +19,11 @@ use std::path::{PathBuf, Path};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
macro_rules! t {
|
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 {
|
($e:expr) => (match $e {
|
||||||
Ok(e) => e,
|
Ok(e) => e,
|
||||||
Err(e) => panic!("{} failed with {}", stringify!($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)) {
|
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 entry = t!(entry);
|
||||||
let kind = t!(entry.file_type());
|
let kind = t!(entry.file_type());
|
||||||
let path = entry.path();
|
let path = entry.path();
|
||||||
|
|
|
@ -52,7 +52,7 @@ pub fn check(path: &Path, bad: &mut bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
contents.truncate(0);
|
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_cr = contents.contains("ignore-tidy-cr");
|
||||||
let skip_tab = contents.contains("ignore-tidy-tab");
|
let skip_tab = contents.contains("ignore-tidy-tab");
|
||||||
let skip_length = contents.contains("ignore-tidy-linelength");
|
let skip_length = contents.contains("ignore-tidy-linelength");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue