]> git.lizzy.rs Git - rust.git/commitdiff
lintcheck: Slight improvements to the error reporting
authorflip1995 <philipp.krones@embecosm.com>
Tue, 16 Feb 2021 15:58:00 +0000 (16:58 +0100)
committerflip1995 <philipp.krones@embecosm.com>
Tue, 16 Feb 2021 15:58:00 +0000 (16:58 +0100)
clippy_dev/src/lintcheck.rs

index b62784da548d298f8d6482c4bd116cae8ecf0c2d..cd3dd8143d55753b8433d25f83accbc48ec8b617 100644 (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.
 fn build_clippy() {
-    Command::new("cargo")
+    let output = Command::new("cargo")
         .arg("build")
         .output()
         .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
@@ -402,12 +406,14 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> String {
 
 /// lintchecks `main()` function
 pub fn run(clap_config: &ArgMatches) {
-    let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy");
-
     println!("Compiling clippy...");
     build_clippy();
     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!(
         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)));
 
     let file = format!("lintcheck-logs/{}_logs.txt", filename);
+    println!("Writing logs to {}", file);
     write(file, text).unwrap();
 }