1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Tidy checks for source code in this repository
13 //! This program runs all of the various tidy checks for style, cleanliness,
14 //! etc. This is run by default on `make check` and as part of the auto
18 use std::path::{PathBuf, Path};
22 ($e:expr, $p:expr) => (match $e {
24 Err(e) => panic!("{} failed on {} with {}", stringify!($e), ($p).display(), e),
27 ($e:expr) => (match $e {
29 Err(e) => panic!("{} failed with {}", stringify!($e), e),
42 let path = env::args_os().skip(1).next().expect("need an argument");
43 let path = PathBuf::from(path);
46 bins::check(&path, &mut bad);
47 style::check(&path, &mut bad);
48 errors::check(&path, &mut bad);
49 cargo::check(&path, &mut bad);
50 features::check(&path, &mut bad);
51 cargo_lock::check(&path, &mut bad);
52 pal::check(&path, &mut bad);
55 panic!("some tidy checks failed");
59 fn filter_dirs(path: &Path) -> bool {
70 skip.iter().any(|p| path.ends_with(p))
74 fn walk(path: &Path, skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
75 for entry in t!(fs::read_dir(path), path) {
76 let entry = t!(entry);
77 let kind = t!(entry.file_type());
78 let path = entry.path();