lintcheck: Slight improvements to the error reporting

This commit is contained in:
flip1995 2021-02-16 16:58:00 +01:00
parent 2a28ea0bea
commit dd5c9b7dda
No known key found for this signature in database
GPG Key ID: 1CA0DF2AF59D68A5

View File

@ -283,10 +283,14 @@ fn filter_clippy_warnings(line: &str) -> bool {
/// Builds clippy inside the repo to make sure we have a clippy executable we can use. /// Builds clippy inside the repo to make sure we have a clippy executable we can use.
fn build_clippy() { fn build_clippy() {
Command::new("cargo") let output = Command::new("cargo")
.arg("build") .arg("build")
.output() .output()
.expect("Failed to build clippy!"); .expect("Failed to build clippy!");
if !output.status.success() {
eprintln!("Failed to compile Clippy");
eprintln!("stderr: {}", String::from_utf8_lossy(&output.stderr))
}
} }
/// Read a `toml` file and return a list of `CrateSources` that we want to check with clippy /// Read a `toml` file and return a list of `CrateSources` that we want to check with clippy
@ -402,12 +406,14 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> String {
/// lintchecks `main()` function /// lintchecks `main()` function
pub fn run(clap_config: &ArgMatches) { pub fn run(clap_config: &ArgMatches) {
let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy");
println!("Compiling clippy..."); println!("Compiling clippy...");
build_clippy(); build_clippy();
println!("Done compiling"); println!("Done compiling");
let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy")
.canonicalize()
.expect("failed to canonicalize path to clippy binary");
// assert that clippy is found // assert that clippy is found
assert!( assert!(
cargo_clippy_path.is_file(), cargo_clippy_path.is_file(),
@ -484,5 +490,6 @@ pub fn run(clap_config: &ArgMatches) {
.for_each(|(cratename, msg)| text.push_str(&format!("{}: '{}'", cratename, msg))); .for_each(|(cratename, msg)| text.push_str(&format!("{}: '{}'", cratename, msg)));
let file = format!("lintcheck-logs/{}_logs.txt", filename); let file = format!("lintcheck-logs/{}_logs.txt", filename);
println!("Writing logs to {}", file);
write(file, text).unwrap(); write(file, text).unwrap();
} }