Skip to content

Commit 6317683

Browse files
committed
cargo dev crater: fixes and debug prints
1 parent 30d8594 commit 6317683

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

clippy_dev/src/crater.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct Krate {
1717
}
1818

1919
impl KrateSource {
20-
fn new(version: &str, name: &str) -> Self {
20+
fn new(name: &str, version: &str) -> Self {
2121
KrateSource {
2222
version: version.into(),
2323
name: name.into(),
@@ -33,19 +33,24 @@ impl KrateSource {
3333
"https://crates.io/api/v1/crates/{}/{}/download",
3434
self.name, self.version
3535
);
36-
print!("Downloading {}, {}", self.name, self.version);
36+
println!("Downloading {}, {} / {}", self.name, self.version, url);
37+
std::fs::create_dir("target/crater/").unwrap();
3738

38-
let krate_name = format!("{}-{}.crate", &self.name, &self.version);
39+
std::fs::create_dir(&krate_download_dir).unwrap();
40+
std::fs::create_dir(&extract_dir).unwrap();
41+
42+
let krate_name = format!("{}-{}.crate.tar.gz", &self.name, &self.version);
3943
let mut krate_dest = std::fs::File::create(krate_download_dir.join(krate_name)).unwrap();
4044
let mut krate_req = ureq::get(&url).call().unwrap().into_reader();
4145
std::io::copy(&mut krate_req, &mut krate_dest).unwrap();
42-
43-
// extract
4446
let krate = krate_dest;
45-
let tar = flate2::read::GzDecoder::new(krate);
47+
dbg!(&krate);
48+
let tar = flate2::read::GzDecoder::new(&krate);
4649
let mut archiv = tar::Archive::new(tar);
47-
let extracted_path = extract_dir.join(format!("{}-{}/", self.name, self.version));
50+
let extracted_path = extract_dir.join(format!("{}-{}", self.name, self.version));
51+
// println!("ar: p: {:?}", &krate, extracted_path);
4852
archiv.unpack(&extracted_path).expect("Failed to extract!");
53+
// extract
4954

5055
Krate {
5156
version: self.version.clone(),
@@ -71,20 +76,23 @@ fn build_clippy() {
7176
// the main fn
7277
pub fn run() {
7378
let cargo_clippy_path: PathBuf = PathBuf::from("target/debug/cargo-clippy");
74-
let clippy_driver_path: PathBuf = PathBuf::from("target/debug/cargo-driver");
79+
let clippy_driver_path: PathBuf = PathBuf::from("target/debug/clippy-driver");
7580

7681
// crates we want to check:
7782
let krates: Vec<KrateSource> = vec![KrateSource::new("cargo", "0.49.0"), KrateSource::new("regex", "1.4.2")];
7883

84+
println!("Compiling clippy...");
7985
build_clippy();
86+
println!("Done compiling");
87+
8088
// assert that clippy is found
8189
assert!(
8290
cargo_clippy_path.is_file(),
83-
"target/debug/cargo-clippy binary not found!"
91+
"target/debug/cargo-clippy binary not found! {}", cargo_clippy_path.display()
8492
);
8593
assert!(
8694
clippy_driver_path.is_file(),
87-
"target/debug/clippy-driver binary not found!"
95+
"target/debug/clippy-driver binary not found! {}", clippy_driver_path.display()
8896
);
8997

9098
// download and extract the crates, then run clippy on them and collect clippys warnings

0 commit comments

Comments
 (0)