]> git.lizzy.rs Git - rust.git/commitdiff
improve tidy to give you file that failed
authorNiko Matsakis <niko@alum.mit.edu>
Sat, 16 Apr 2016 10:11:18 +0000 (06:11 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 21 Apr 2016 08:42:25 +0000 (04:42 -0400)
the current tidy panics give you no idea why it failed

src/tools/tidy/src/bins.rs
src/tools/tidy/src/cargo.rs
src/tools/tidy/src/main.rs
src/tools/tidy/src/style.rs

index 84d3ff2b238bbceeb88f11ebc3bc34d63045d6d3..43475f203d57ced698b2b34c4b25cc9c255e7c2e 100644 (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;
index a170ecfdce096d6fef1a28c84611ff06eb9e0fb8..77dcf9c1bd81fdb180b5e35b1e166a5cc096c6b5 100644 (file)
@@ -20,7 +20,7 @@
 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() {
index 85b9c345e199c4349728603726d3a50e113c2586..e9e2508aba9bd022ec700ae8d73f2de8c586746d 100644 (file)
 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();
index 4c5f72c1e7960d3b4085a5e9edcab7470bd80aad..61230b3b030e53818112bb92c0b65809fafcfa79 100644 (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");