Skip to content

Commit 69c0757

Browse files
committed
clippy cargo dev: fix checking of crates
1 parent e691474 commit 69c0757

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

clippy_dev/src/crater.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,30 @@ impl KrateSource {
5050
let ungz_tar = flate2::read::GzDecoder::new(dl);
5151
// extract the tar archive
5252
let mut archiv = tar::Archive::new(ungz_tar);
53-
let extract_path = extract_dir.join(format!("{}-{}/", self.name, self.version));
53+
let extract_path = extract_dir.clone();
5454
archiv.unpack(&extract_path).expect("Failed to extract!");
5555
// extracted
56-
56+
dbg!(&extract_path);
5757
Krate {
5858
version: self.version.clone(),
5959
name: self.name.clone(),
60-
path: extract_path,
60+
path: extract_dir.join(format!("{}-{}/", self.name, self.version))
6161
}
6262
}
6363
}
6464

6565
impl Krate {
66-
fn run_clippy_lints(&self) -> String {
67-
todo!();
66+
fn run_clippy_lints(&self, cargo_clippy_path: &PathBuf) -> String {
67+
let cargo_clippy_path = std::fs::canonicalize(cargo_clippy_path).unwrap();
68+
let project_root = &self.path;
69+
dbg!(&cargo_clippy_path);
70+
dbg!(&project_root);
71+
72+
let output = std::process::Command::new(cargo_clippy_path).current_dir(project_root).output();
73+
dbg!(&output);
74+
let output = String::from_utf8_lossy(&output.unwrap().stderr).into_owned();
75+
dbg!(&output);
76+
output
6877
}
6978
}
7079

@@ -81,7 +90,7 @@ pub fn run() {
8190
let clippy_driver_path: PathBuf = PathBuf::from("target/debug/clippy-driver");
8291

8392
// crates we want to check:
84-
let krates: Vec<KrateSource> = vec![KrateSource::new("cargo", "0.49.0"), KrateSource::new("regex", "1.4.2")];
93+
let krates: Vec<KrateSource> = vec![KrateSource::new("regex", "1.4.2"), KrateSource::new("cargo", "0.49.0"), ];
8594

8695
println!("Compiling clippy...");
8796
build_clippy();
@@ -97,12 +106,12 @@ pub fn run() {
97106
clippy_driver_path.is_file(),
98107
"target/debug/clippy-driver binary not found! {}",
99108
clippy_driver_path.display()
100-
);
109+
);
101110

102111
// download and extract the crates, then run clippy on them and collect clippys warnings
103112
let _clippy_lint_results: Vec<String> = krates
104113
.into_iter()
105114
.map(|krate| krate.download_and_extract())
106-
.map(|krate| krate.run_clippy_lints())
115+
.map(|krate| krate.run_clippy_lints(&cargo_clippy_path))
107116
.collect::<Vec<String>>();
108117
}

0 commit comments

Comments
 (0)