]> git.lizzy.rs Git - rust.git/commitdiff
cargo dev crater: lay out the base plan
authorMatthias Krüger <matthias.krueger@famsik.de>
Fri, 18 Dec 2020 12:21:13 +0000 (13:21 +0100)
committerMatthias Krüger <matthias.krueger@famsik.de>
Sat, 23 Jan 2021 01:18:11 +0000 (02:18 +0100)
clippy_dev/src/crater.rs [new file with mode: 0644]
clippy_dev/src/lib.rs

diff --git a/clippy_dev/src/crater.rs b/clippy_dev/src/crater.rs
new file mode 100644 (file)
index 0000000..fe0fc44
--- /dev/null
@@ -0,0 +1,69 @@
+use std::path::PathBuf;
+use std::process::Command;
+
+// represents an archive we download from crates.io
+struct KrateSource {
+    version: String,
+    name: String,
+}
+
+// represents the extracted sourcecode of a crate
+struct Krate {
+    version: String,
+    name: String,
+}
+
+impl KrateSource {
+    fn new(version: &str, name: &str) -> Self {
+        KrateSource {
+            version: version.into(),
+            name: name.into(),
+        }
+    }
+    fn download_and_extract(self) -> Krate {
+        // download
+        // extract
+
+        Krate {
+            version: self.version,
+            name: self.name,
+        }
+    }
+}
+
+impl Krate {
+    fn run_clippy_lints(&self) -> String {
+        todo!();
+    }
+
+
+}
+
+fn build_clippy() {
+    Command::new("cargo")
+        .arg("build")
+        .output()
+        .expect("Failed to build clippy!");
+}
+
+// the main fn
+pub(crate) fn run() {
+    let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy");
+    let clippy_driver_path: PathBuf = PathBuf::from("target/debug/cargo-driver");
+
+    // crates we want to check:
+    let krates: Vec<KrateSource> = vec![KrateSource::new("cargo", "0.49.0"), KrateSource::new("regex", "1.4.2")];
+
+    build_clippy();
+    // assert that clippy is found
+    assert!(
+        cargo_clippy_path.is_file(),
+        "target/debug/cargo-clippy binary not found!"
+    );
+    assert!(
+        clippy_driver_path.is_file(),
+        "target/debug/clippy-driver binary not found!"
+    );
+
+  let clippy_lint_results: Vec<String> = krates.into_iter().map(|krate|  krate.download_and_extract()).map(|krate| krate.run_clippy_lints()).collect::<Vec<String>>();
+}
index 17cc08ee10fea312f5b3d392991f61326be4f362..4873769b367e9cbccde6dc8fd9c2a193057ad1f2 100644 (file)
@@ -11,6 +11,7 @@
 use walkdir::WalkDir;
 
 pub mod bless;
+pub mod crater;
 pub mod fmt;
 pub mod new_lint;
 pub mod ra_setup;