about summary refs log tree commit diff
path: root/clippy_dev
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-02-09 16:27:56 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2021-02-11 10:41:31 +0100
commitc7241b6e5e0666a03ac10f4b48440db10dc748dc (patch)
tree5a8f62c8d18fee69940397f5917aa1998424e093 /clippy_dev
parent1025cd349d1c1727e37f0d2835b34f6f48d91986 (diff)
downloadrust-c7241b6e5e0666a03ac10f4b48440db10dc748dc.tar.gz
rust-c7241b6e5e0666a03ac10f4b48440db10dc748dc.zip
lintcheck: make the log file be ${source-file}-logs.txt
this allows us to check multiple source.tomls and not worry about overriding our logfiles accidentally
Diffstat (limited to 'clippy_dev')
-rw-r--r--clippy_dev/src/lintcheck.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/clippy_dev/src/lintcheck.rs b/clippy_dev/src/lintcheck.rs
index 3fc7dcb7d4b..faf13543f18 100644
--- a/clippy_dev/src/lintcheck.rs
+++ b/clippy_dev/src/lintcheck.rs
@@ -192,8 +192,10 @@ fn build_clippy() {
 }
 
 // get a list of CrateSources we want to check from a "lintcheck_crates.toml" file.
-fn read_crates(toml_path: Option<&str>) -> Vec<CrateSource> {
+fn read_crates(toml_path: Option<&str>) -> (String, Vec<CrateSource>) {
     let toml_path = PathBuf::from(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml"));
+    // save it so that we can use the name of the sources.toml as name for the logfile later.
+    let toml_filename = toml_path.file_stem().unwrap().to_str().unwrap().to_string();
     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 =
@@ -237,7 +239,7 @@ fn read_crates(toml_path: Option<&str>) -> Vec<CrateSource> {
             unreachable!("Failed to translate TomlCrate into CrateSource!");
         }
     });
-    crate_sources
+    (toml_filename, crate_sources)
 }
 
 // extract interesting data from a json lint message
@@ -288,7 +290,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(clap_config.value_of("crates-toml"));
+    let (filename, 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
@@ -351,5 +353,6 @@ pub fn run(clap_config: &ArgMatches) {
     // save the text into lintcheck-logs/logs.txt
     let mut text = clippy_ver; // clippy version number on top
     text.push_str(&format!("\n{}", all_msgs.join("")));
-    write("lintcheck-logs/logs.txt", text).unwrap();
+    let file = format!("lintcheck-logs/{}_logs.txt", filename);
+    write(file, text).unwrap();
 }