mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 00:47:16 +00:00
cargo dev crater: throw an error if we can't find our specified crate in the .toml list
This commit is contained in:
parent
b6ef1e282e
commit
ec1902ce43
3 changed files with 48 additions and 25 deletions
|
@ -4,20 +4,22 @@ version = "0.0.1"
|
|||
authors = ["Philipp Hansch <dev@phansch.net>"]
|
||||
edition = "2018"
|
||||
|
||||
|
||||
[dependencies]
|
||||
bytecount = "0.6"
|
||||
clap = "2.33"
|
||||
flate2 = "1.0.19"
|
||||
flate2 = { version = "1.0.19" , optional = true}
|
||||
itertools = "0.9"
|
||||
opener = "0.4"
|
||||
regex = "1"
|
||||
serde = {version = "1.0", features = ["derive"]}
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"]}
|
||||
serde_json = { version = "1.0" , optional = true}
|
||||
shell-escape = "0.1"
|
||||
tar = "0.4.30"
|
||||
toml = "0.5"
|
||||
ureq = "2.0.0-rc3"
|
||||
tar = { version = "0.4.30" , optional = true}
|
||||
toml = { version = "0.5" , optional = true}
|
||||
ureq = { version = "2.0.0-rc3" , optional = true}
|
||||
walkdir = "2"
|
||||
|
||||
[features]
|
||||
crater = ["flate2", "serde_json", "tar", "toml", "ureq"]
|
||||
deny-warnings = []
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// When a new lint is introduced, we can search the results for new warnings and check for false
|
||||
// positives.
|
||||
|
||||
#![cfg(feature = "crater")]
|
||||
#![allow(clippy::filter_map)]
|
||||
|
||||
use crate::clippy_project_root;
|
||||
|
@ -218,9 +219,20 @@ pub fn run(clap_config: &ArgMatches) {
|
|||
// download and extract the crates, then run clippy on them and collect clippys warnings
|
||||
// flatten into one big list of warnings
|
||||
|
||||
let crates = read_crates();
|
||||
|
||||
let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
|
||||
// only check a single
|
||||
read_crates()
|
||||
// if we don't have the specified crated in the .toml, throw an error
|
||||
if !crates.iter().any(|krate| krate.name == only_one_crate) {
|
||||
eprintln!(
|
||||
"ERROR: could not find crate '{}' in clippy_dev/crater_crates.toml",
|
||||
only_one_crate
|
||||
);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// only check a single crate that was passed via cmdline
|
||||
crates
|
||||
.into_iter()
|
||||
.map(|krate| krate.download_and_extract())
|
||||
.filter(|krate| krate.name == only_one_crate)
|
||||
|
@ -228,7 +240,8 @@ pub fn run(clap_config: &ArgMatches) {
|
|||
.flatten()
|
||||
.collect()
|
||||
} else {
|
||||
read_crates()
|
||||
// check all crates (default)
|
||||
crates
|
||||
.into_iter()
|
||||
.map(|krate| krate.download_and_extract())
|
||||
.map(|krate| krate.run_clippy_lints(&cargo_clippy_path))
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
||||
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use clippy_dev::{bless, crater, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
|
||||
use clippy_dev::{bless, fmt, new_lint, ra_setup, serve, stderr_length_check, update_lints};
|
||||
|
||||
#[cfg(feature = "crater")]
|
||||
use clippy_dev::crater;
|
||||
|
||||
fn main() {
|
||||
let matches = get_clap_config();
|
||||
|
@ -10,6 +13,7 @@ fn main() {
|
|||
("bless", Some(matches)) => {
|
||||
bless::bless(matches.is_present("ignore-timestamp"));
|
||||
},
|
||||
#[cfg(feature = "crater")]
|
||||
("crater", Some(matches)) => {
|
||||
crater::run(&matches);
|
||||
},
|
||||
|
@ -49,8 +53,19 @@ fn main() {
|
|||
}
|
||||
|
||||
fn get_clap_config<'a>() -> ArgMatches<'a> {
|
||||
App::new("Clippy developer tooling")
|
||||
.subcommand(
|
||||
#[cfg(feature = "crater")]
|
||||
let crater_sbcmd = SubCommand::with_name("crater")
|
||||
.about("run clippy on a set of crates and check output")
|
||||
.arg(
|
||||
Arg::with_name("only")
|
||||
.takes_value(true)
|
||||
.value_name("CRATE")
|
||||
.long("only")
|
||||
.help("only process a single crate of the list"),
|
||||
);
|
||||
|
||||
let app = App::new("Clippy developer tooling")
|
||||
.subcommand(
|
||||
SubCommand::with_name("bless")
|
||||
.about("bless the test output changes")
|
||||
.arg(
|
||||
|
@ -59,17 +74,6 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
|
|||
.help("Include files updated before clippy was built"),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("crater")
|
||||
.about("run clippy on a set of crates and check output")
|
||||
.arg(
|
||||
Arg::with_name("only")
|
||||
.takes_value(true)
|
||||
.value_name("CRATE")
|
||||
.long("only")
|
||||
.help("only process a single crate of the list"),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("fmt")
|
||||
.about("Run rustfmt on all projects and tests")
|
||||
|
@ -177,6 +181,10 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
|
|||
.validator_os(serve::validate_port),
|
||||
)
|
||||
.arg(Arg::with_name("lint").help("Which lint's page to load initially (optional)")),
|
||||
)
|
||||
.get_matches()
|
||||
);
|
||||
|
||||
#[cfg(feature = "crater")]
|
||||
let app = app.subcommand(crater_sbcmd);
|
||||
|
||||
app.get_matches()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue