Skip to content

Commit 64982cc

Browse files
committed
lintcheck: make TomlCrate also accept git-data from lintcheck_crates.toml
1 parent cb30219 commit 64982cc

File tree

2 files changed

+38
-28
lines changed

2 files changed

+38
-28
lines changed

clippy_dev/lintcheck_crates.toml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[crates]
22
# some of these are from cargotest
3-
cargo = ['0.49.0']
4-
iron = ['0.6.1']
5-
ripgrep = ['12.1.1']
6-
xsv = ['0.13.0']
7-
#tokei = ['12.0.4']
8-
rayon = ['1.5.0']
9-
serde = ['1.0.118']
3+
cargo = {name = "cargo", versions = ['0.49.0']}
4+
iron = {name = "iron", versions = ['0.6.1']}
5+
ripgrep = {name = "ripgrep", versions = ['12.1.1']}
6+
xsv = {name = "xsv", versions = ['0.13.0']}
7+
#tokei = { name = "tokei", versions = ['12.0.4']}
8+
rayon = {name = "rayon", versions = ['1.5.0']}
9+
serde = {name = "serde", versions = ['1.0.118']}
1010
# top 10 crates.io dls
11-
bitflags = ['1.2.1']
12-
libc = ['0.2.81']
13-
log = ['0.4.11']
14-
proc-macro2 = ['1.0.24']
15-
quote = ['1.0.7']
16-
rand = ['0.7.3']
17-
rand_core = ['0.6.0']
18-
regex = ['1.3.2']
19-
syn = ['1.0.54']
20-
unicode-xid = ['0.2.1']
11+
bitflags = {name = "bitflags", versions = ['1.2.1']}
12+
libc = {name = "libc", versions = ['0.2.81']}
13+
log = {name = "log", versions = ['0.4.11']}
14+
proc-macro2 = {name = "proc-macro2", versions = ['1.0.24']}
15+
quote = {name = "quote", versions = ['1.0.7']}
16+
rand = {name = "rand", versions = ['0.7.3']}
17+
rand_core = {name = "rand_core", versions = ['0.6.0']}
18+
regex = {name = "regex", versions = ['1.3.2']}
19+
syn = {name = "syn", versions = ['1.0.54']}
20+
unicode-xid = {name = "unicode-xid", versions = ['0.2.1']}

clippy_dev/src/lintcheck.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ use serde_json::Value;
2020
// use this to store the crates when interacting with the crates.toml file
2121
#[derive(Debug, Serialize, Deserialize)]
2222
struct CrateList {
23-
crates: HashMap<String, Vec<String>>,
23+
crates: HashMap<String, TomlCrate>,
2424
}
2525

2626
// crate data we stored in the toml, can have multiple versions per crate
2727
// A single TomlCrate is laster mapped to several CrateSources in that case
28+
#[derive(Debug, Serialize, Deserialize)]
2829
struct TomlCrate {
2930
name: String,
30-
versions: Vec<String>,
31+
versions: Option<Vec<String>>,
32+
git_url: Option<String>,
33+
git_hash: Option<String>,
3134
}
3235

3336
// represents an archive we download from crates.io
@@ -114,7 +117,7 @@ impl Crate {
114117

115118
let shared_target_dir = clippy_project_root().join("target/lintcheck/shared_target_dir/");
116119

117-
let all_output = std::process::Command::new(cargo_clippy_path)
120+
let all_output = std::process::Command::new(&cargo_clippy_path)
118121
.env("CARGO_TARGET_DIR", shared_target_dir)
119122
// lint warnings will look like this:
120123
// src/cargo/ops/cargo_compile.rs:127:35: warning: usage of `FromIterator::from_iter`
@@ -128,7 +131,12 @@ impl Crate {
128131
])
129132
.current_dir(&self.path)
130133
.output()
131-
.unwrap();
134+
.unwrap_or_else(|error| {
135+
dbg!(error);
136+
dbg!(&cargo_clippy_path);
137+
dbg!(&self.path);
138+
panic!("something was not found?")
139+
});
132140
let stdout = String::from_utf8_lossy(&all_output.stdout);
133141
let output_lines = stdout.lines();
134142
//dbg!(&output_lines);
@@ -160,19 +168,21 @@ fn read_crates() -> Vec<CrateSource> {
160168
let tomlcrates: Vec<TomlCrate> = crate_list
161169
.crates
162170
.into_iter()
163-
.map(|(name, versions)| TomlCrate { name, versions })
171+
.map(|(_cratename, tomlcrate)| tomlcrate)
164172
.collect();
165173

166174
// flatten TomlCrates into CrateSources (one TomlCrates may represent several versions of a crate =>
167175
// multiple Cratesources)
168176
let mut crate_sources = Vec::new();
169177
tomlcrates.into_iter().for_each(|tk| {
170-
tk.versions.iter().for_each(|ver| {
171-
crate_sources.push(CrateSource {
172-
name: tk.name.clone(),
173-
version: ver.to_string(),
174-
});
175-
})
178+
if let Some(ref versions) = tk.versions {
179+
versions.iter().for_each(|ver| {
180+
crate_sources.push(CrateSource {
181+
name: tk.name.clone(),
182+
version: ver.to_string(),
183+
});
184+
})
185+
}
176186
});
177187
crate_sources
178188
}

0 commit comments

Comments
 (0)