Skip to content

Commit c7241b6

Browse files
committed
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
1 parent 1025cd3 commit c7241b6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

clippy_dev/src/lintcheck.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ fn build_clippy() {
192192
}
193193

194194
// get a list of CrateSources we want to check from a "lintcheck_crates.toml" file.
195-
fn read_crates(toml_path: Option<&str>) -> Vec<CrateSource> {
195+
fn read_crates(toml_path: Option<&str>) -> (String, Vec<CrateSource>) {
196196
let toml_path = PathBuf::from(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml"));
197+
// save it so that we can use the name of the sources.toml as name for the logfile later.
198+
let toml_filename = toml_path.file_stem().unwrap().to_str().unwrap().to_string();
197199
let toml_content: String =
198200
std::fs::read_to_string(&toml_path).unwrap_or_else(|_| panic!("Failed to read {}", toml_path.display()));
199201
let crate_list: CrateList =
@@ -237,7 +239,7 @@ fn read_crates(toml_path: Option<&str>) -> Vec<CrateSource> {
237239
unreachable!("Failed to translate TomlCrate into CrateSource!");
238240
}
239241
});
240-
crate_sources
242+
(toml_filename, crate_sources)
241243
}
242244

243245
// extract interesting data from a json lint message
@@ -288,7 +290,7 @@ pub fn run(clap_config: &ArgMatches) {
288290
// download and extract the crates, then run clippy on them and collect clippys warnings
289291
// flatten into one big list of warnings
290292

291-
let crates = read_crates(clap_config.value_of("crates-toml"));
293+
let (filename, crates) = read_crates(clap_config.value_of("crates-toml"));
292294

293295
let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
294296
// if we don't have the specified crate in the .toml, throw an error
@@ -351,5 +353,6 @@ pub fn run(clap_config: &ArgMatches) {
351353
// save the text into lintcheck-logs/logs.txt
352354
let mut text = clippy_ver; // clippy version number on top
353355
text.push_str(&format!("\n{}", all_msgs.join("")));
354-
write("lintcheck-logs/logs.txt", text).unwrap();
356+
let file = format!("lintcheck-logs/{}_logs.txt", filename);
357+
write(file, text).unwrap();
355358
}
File renamed without changes.

0 commit comments

Comments
 (0)