about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-07 19:04:00 +0000
committerbors <bors@rust-lang.org>2021-02-07 19:04:00 +0000
commitde35c297bf7464e891ada4899470b60aa60db87f (patch)
tree6016d4c7253976afb7a980ba6fb3e08ce3d3bfe6
parentc1ce78f0b2871763fea2bc39194a691bc35c9d29 (diff)
parent6f3eeac83c801434bd36e2435c9fafab8af5576c (diff)
downloadrust-de35c297bf7464e891ada4899470b60aa60db87f.tar.gz
rust-de35c297bf7464e891ada4899470b60aa60db87f.zip
Auto merge of #6694 - matthiaskrgr:lintcheck-cfg, r=Manishearth
lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.

Fixes #6691

changelog: lintcheck: add --crates-toml  cmdline option to override default crates.toml file.
-rw-r--r--clippy_dev/src/lintcheck.rs6
-rw-r--r--clippy_dev/src/main.rs7
2 files changed, 10 insertions, 3 deletions
diff --git a/clippy_dev/src/lintcheck.rs b/clippy_dev/src/lintcheck.rs
index d73405c9337..3fc7dcb7d4b 100644
--- a/clippy_dev/src/lintcheck.rs
+++ b/clippy_dev/src/lintcheck.rs
@@ -192,8 +192,8 @@ fn build_clippy() {
 }
 
 // get a list of CrateSources we want to check from a "lintcheck_crates.toml" file.
-fn read_crates() -> Vec<CrateSource> {
-    let toml_path = PathBuf::from("clippy_dev/lintcheck_crates.toml");
+fn read_crates(toml_path: Option<&str>) -> Vec<CrateSource> {
+    let toml_path = PathBuf::from(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml"));
     let toml_content: String =
         std::fs::read_to_string(&toml_path).unwrap_or_else(|_| panic!("Failed to read {}", toml_path.display()));
     let crate_list: CrateList =
@@ -288,7 +288,7 @@ 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 crates = read_crates(clap_config.value_of("crates-toml"));
 
     let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
         // if we don't have the specified crate in the .toml, throw an error
diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs
index e7a298a37e1..5dbd46935a5 100644
--- a/clippy_dev/src/main.rs
+++ b/clippy_dev/src/main.rs
@@ -62,6 +62,13 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
                 .value_name("CRATE")
                 .long("only")
                 .help("only process a single crate of the list"),
+        )
+        .arg(
+            Arg::with_name("crates-toml")
+                .takes_value(true)
+                .value_name("CRATES-SOURCES-TOML-PATH")
+                .long("crates-toml")
+                .help("set the path for a crates.toml where lintcheck should read the sources from"),
         );
 
     let app = App::new("Clippy developer tooling")