about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-02-05 23:13:59 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2021-02-06 12:10:45 +0100
commit64982cc435fc4546cbdc9ce3935cdd63ac636e4e (patch)
tree8da2b8a4074aab818bdb2d7851f7d6f1ca1875b5
parentcb3021999c87b480db0a5fd8f7fb2a06f3ffa1ed (diff)
downloadrust-64982cc435fc4546cbdc9ce3935cdd63ac636e4e.tar.gz
rust-64982cc435fc4546cbdc9ce3935cdd63ac636e4e.zip
lintcheck: make TomlCrate also accept git-data from lintcheck_crates.toml
-rw-r--r--clippy_dev/lintcheck_crates.toml34
-rw-r--r--clippy_dev/src/lintcheck.rs32
2 files changed, 38 insertions, 28 deletions
diff --git a/clippy_dev/lintcheck_crates.toml b/clippy_dev/lintcheck_crates.toml
index 1fbf7930d3e..657efb16233 100644
--- a/clippy_dev/lintcheck_crates.toml
+++ b/clippy_dev/lintcheck_crates.toml
@@ -1,20 +1,20 @@
 [crates]
 # some of these are from cargotest
-cargo = ['0.49.0']
-iron = ['0.6.1']
-ripgrep = ['12.1.1']
-xsv = ['0.13.0']
-#tokei = ['12.0.4']
-rayon = ['1.5.0']
-serde = ['1.0.118']
+cargo = {name = "cargo", versions = ['0.49.0']}
+iron = {name = "iron", versions = ['0.6.1']}
+ripgrep = {name = "ripgrep", versions = ['12.1.1']}
+xsv = {name = "xsv", versions = ['0.13.0']}
+#tokei = { name = "tokei", versions = ['12.0.4']}
+rayon = {name = "rayon", versions = ['1.5.0']}
+serde = {name = "serde", versions = ['1.0.118']}
 # top 10 crates.io dls
-bitflags = ['1.2.1']
-libc = ['0.2.81']
-log = ['0.4.11']
-proc-macro2 = ['1.0.24']
-quote = ['1.0.7']
-rand = ['0.7.3']
-rand_core = ['0.6.0']
-regex = ['1.3.2']
-syn = ['1.0.54']
-unicode-xid = ['0.2.1']
+bitflags = {name = "bitflags", versions = ['1.2.1']}
+libc = {name = "libc", versions = ['0.2.81']}
+log = {name = "log", versions = ['0.4.11']}
+proc-macro2 = {name = "proc-macro2", versions = ['1.0.24']}
+quote = {name = "quote", versions = ['1.0.7']}
+rand = {name = "rand", versions = ['0.7.3']}
+rand_core = {name = "rand_core", versions = ['0.6.0']}
+regex = {name = "regex", versions = ['1.3.2']}
+syn = {name = "syn", versions = ['1.0.54']}
+unicode-xid = {name = "unicode-xid", versions = ['0.2.1']}
diff --git a/clippy_dev/src/lintcheck.rs b/clippy_dev/src/lintcheck.rs
index 785c692d3cb..e3587c7bdfe 100644
--- a/clippy_dev/src/lintcheck.rs
+++ b/clippy_dev/src/lintcheck.rs
@@ -20,14 +20,17 @@ use serde_json::Value;
 // use this to store the crates when interacting with the crates.toml file
 #[derive(Debug, Serialize, Deserialize)]
 struct CrateList {
-    crates: HashMap<String, Vec<String>>,
+    crates: HashMap<String, TomlCrate>,
 }
 
 // crate data we stored in the toml, can have multiple versions per crate
 // A single TomlCrate is laster mapped to several CrateSources in that case
+#[derive(Debug, Serialize, Deserialize)]
 struct TomlCrate {
     name: String,
-    versions: Vec<String>,
+    versions: Option<Vec<String>>,
+    git_url: Option<String>,
+    git_hash: Option<String>,
 }
 
 // represents an archive we download from crates.io
@@ -114,7 +117,7 @@ impl Crate {
 
         let shared_target_dir = clippy_project_root().join("target/lintcheck/shared_target_dir/");
 
-        let all_output = std::process::Command::new(cargo_clippy_path)
+        let all_output = std::process::Command::new(&cargo_clippy_path)
             .env("CARGO_TARGET_DIR", shared_target_dir)
             // lint warnings will look like this:
             // src/cargo/ops/cargo_compile.rs:127:35: warning: usage of `FromIterator::from_iter`
@@ -128,7 +131,12 @@ impl Crate {
             ])
             .current_dir(&self.path)
             .output()
-            .unwrap();
+            .unwrap_or_else(|error| {
+                dbg!(error);
+                dbg!(&cargo_clippy_path);
+                dbg!(&self.path);
+                panic!("something was not found?")
+            });
         let stdout = String::from_utf8_lossy(&all_output.stdout);
         let output_lines = stdout.lines();
         //dbg!(&output_lines);
@@ -160,19 +168,21 @@ fn read_crates() -> Vec<CrateSource> {
     let tomlcrates: Vec<TomlCrate> = crate_list
         .crates
         .into_iter()
-        .map(|(name, versions)| TomlCrate { name, versions })
+        .map(|(_cratename, tomlcrate)| tomlcrate)
         .collect();
 
     // flatten TomlCrates into CrateSources (one TomlCrates may represent several versions of a crate =>
     // multiple Cratesources)
     let mut crate_sources = Vec::new();
     tomlcrates.into_iter().for_each(|tk| {
-        tk.versions.iter().for_each(|ver| {
-            crate_sources.push(CrateSource {
-                name: tk.name.clone(),
-                version: ver.to_string(),
-            });
-        })
+        if let Some(ref versions) = tk.versions {
+            versions.iter().for_each(|ver| {
+                crate_sources.push(CrateSource {
+                    name: tk.name.clone(),
+                    version: ver.to_string(),
+                });
+            })
+        }
     });
     crate_sources
 }