]> git.lizzy.rs Git - rust.git/blob - src/tools/tidy/src/main.rs
Auto merge of #78965 - jryans:emscripten-threads-libc, r=kennytm
[rust.git] / src / tools / tidy / src / main.rs
1 //! Tidy checks source code in this repository.
2 //!
3 //! This program runs all of the various tidy checks for style, cleanliness,
4 //! etc. This is run by default on `./x.py test` and as part of the auto
5 //! builders. The tidy checks can be executed with `./x.py test tidy`.
6
7 use tidy::*;
8
9 use std::env;
10 use std::path::PathBuf;
11 use std::process;
12
13 fn main() {
14     let root_path: PathBuf = env::args_os().nth(1).expect("need path to root of repo").into();
15     let cargo: PathBuf = env::args_os().nth(2).expect("need path to cargo").into();
16     let output_directory: PathBuf =
17         env::args_os().nth(3).expect("need path to output directory").into();
18
19     let src_path = root_path.join("src");
20     let library_path = root_path.join("library");
21     let compiler_path = root_path.join("compiler");
22
23     let args: Vec<String> = env::args().skip(1).collect();
24
25     let mut bad = false;
26     let verbose = args.iter().any(|s| *s == "--verbose");
27
28     // Checks over tests.
29     debug_artifacts::check(&src_path, &mut bad);
30     ui_tests::check(&src_path, &mut bad);
31
32     // Checks that only make sense for the compiler.
33     errors::check(&compiler_path, &mut bad);
34     error_codes_check::check(&src_path, &mut bad);
35
36     // Checks that only make sense for the std libs.
37     pal::check(&library_path, &mut bad);
38     unit_tests::check(&library_path, &mut bad);
39
40     // Checks that need to be done for both the compiler and std libraries.
41     bins::check(&src_path, &output_directory, &mut bad);
42     bins::check(&compiler_path, &output_directory, &mut bad);
43     bins::check(&library_path, &output_directory, &mut bad);
44
45     style::check(&src_path, &mut bad);
46     style::check(&compiler_path, &mut bad);
47     style::check(&library_path, &mut bad);
48
49     cargo::check(&src_path, &mut bad);
50     cargo::check(&compiler_path, &mut bad);
51     cargo::check(&library_path, &mut bad);
52
53     edition::check(&src_path, &mut bad);
54     edition::check(&compiler_path, &mut bad);
55     edition::check(&library_path, &mut bad);
56
57     let collected = features::check(&src_path, &compiler_path, &library_path, &mut bad, verbose);
58     unstable_book::check(&src_path, collected, &mut bad);
59
60     // Checks that are done on the cargo workspace.
61     deps::check(&root_path, &cargo, &mut bad);
62     extdeps::check(&root_path, &mut bad);
63
64     if bad {
65         eprintln!("some tidy checks failed");
66         process::exit(1);
67     }
68 }