From 37c4b11a84eb07c0d9a0b95ad81a7ae72ec1370a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 4 Mar 2021 22:33:22 +0100 Subject: [PATCH 1/2] lintcheck: add test --- clippy_dev/src/lintcheck.rs | 32 +++++++++++++++++++++++++++++++- clippy_dev/test_sources.toml | 4 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 clippy_dev/test_sources.toml diff --git a/clippy_dev/src/lintcheck.rs b/clippy_dev/src/lintcheck.rs index 977ff771a99f4..01f3c9a5bd8a2 100644 --- a/clippy_dev/src/lintcheck.rs +++ b/clippy_dev/src/lintcheck.rs @@ -503,6 +503,10 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> (String, HashMap<&String, /// check if the latest modification of the logfile is older than the modification date of the /// clippy binary, if this is true, we should clean the lintchec shared target directory and recheck fn lintcheck_needs_rerun(lintcheck_logs_path: &Path) -> bool { + if !lintcheck_logs_path.exists() { + return true; + } + let clippy_modified: std::time::SystemTime = { let mut times = [CLIPPY_DRIVER_PATH, CARGO_CLIPPY_PATH].iter().map(|p| { std::fs::metadata(p) @@ -665,7 +669,6 @@ fn read_stats_from_file(file_path: &Path) -> HashMap { let file_content: String = match std::fs::read_to_string(file_path).ok() { Some(content) => content, None => { - eprintln!("RETURND"); return HashMap::new(); }, }; @@ -734,3 +737,30 @@ fn print_stats(old_stats: HashMap, new_stats: HashMap<&String, us println!("{} {} => 0", old_key, old_value); }); } + +#[test] +fn lintcheck_test() { + let args = [ + "run", + "--target-dir", + "clippy_dev/target", + "--package", + "clippy_dev", + "--bin", + "clippy_dev", + "--manifest-path", + "clippy_dev/Cargo.toml", + "--features", + "lintcheck", + "--", + "lintcheck", + "--crates-toml", + "clippy_dev/test_sources.toml", + ]; + let status = std::process::Command::new("cargo") + .args(&args) + .current_dir("../" /* repo root */) + .status(); + + assert!(status.unwrap().success()); +} diff --git a/clippy_dev/test_sources.toml b/clippy_dev/test_sources.toml new file mode 100644 index 0000000000000..4b0eb71ef4bfe --- /dev/null +++ b/clippy_dev/test_sources.toml @@ -0,0 +1,4 @@ +[crates] +cc = {name = "cc", versions = ['1.0.67']} +home = {name = "home", git_url = "https://github.com/brson/home", git_hash = "32044e53dfbdcd32bafad3109d1fbab805fc0f40"} +rustc_tools_util = {name = "rustc_tools_util", versions = ['0.2.0']} From 3f7ad32a997c4947e7f010abe980862a2ff21f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Thu, 4 Mar 2021 22:40:04 +0100 Subject: [PATCH 2/2] update lintcheck logs --- lintcheck-logs/lintcheck_crates_logs.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lintcheck-logs/lintcheck_crates_logs.txt b/lintcheck-logs/lintcheck_crates_logs.txt index 167024b3a056b..47453f362547a 100644 --- a/lintcheck-logs/lintcheck_crates_logs.txt +++ b/lintcheck-logs/lintcheck_crates_logs.txt @@ -1,4 +1,4 @@ -clippy 0.1.52 (70d952e75 2021-02-28) +clippy 0.1.52 (37c4b11a8 2021-03-04) target/lintcheck/sources/anyhow-1.0.38/build.rs:1:null clippy::cargo_common_metadata "package `anyhow` is missing `package.keywords` metadata" target/lintcheck/sources/anyhow-1.0.38/src/error.rs:350:5 clippy::missing_panics_doc "docs for function which may panic missing `# Panics` section" @@ -99,6 +99,7 @@ target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:1:null clippy::multi target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:1:null clippy::multiple_crate_versions "multiple versions for dependency `hex`: 0.3.2, 0.4.0" target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:1:null clippy::multiple_crate_versions "multiple versions for dependency `humantime`: 1.3.0, 2.0.0" target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:72:22 clippy::redundant_closure_for_method_calls "redundant closure found" +target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:79:40 clippy::manual_map "manual implementation of `Option::map`" target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:94:13 clippy::match_wildcard_for_single_variants "wildcard match will miss any future added variants" target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:96:41 clippy::redundant_closure_for_method_calls "redundant closure found" target/lintcheck/sources/cargo-0.49.0/src/bin/cargo/main.rs:98:60 clippy::redundant_closure_for_method_calls "redundant closure found" @@ -1208,6 +1209,7 @@ target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/mod.rs:689:20 clippy target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/mod.rs:699:5 clippy::fn_params_excessive_bools "more than 3 bools in function parameters" target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/mod.rs:699:5 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section" target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/mod.rs:719:58 clippy::redundant_closure_for_method_calls "redundant closure found" +target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/mod.rs:748:30 clippy::manual_map "manual implementation of `Option::map`" target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/mod.rs:816:5 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section" target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/path.rs:10:1 clippy::module_name_repetitions "item name ends with its containing module's name" target/lintcheck/sources/cargo-0.49.0/src/cargo/util/config/path.rs:14:5 clippy::must_use_candidate "this method could have a `#[must_use]` attribute" @@ -1463,6 +1465,7 @@ target/lintcheck/sources/cfg-expr-0.7.1/src/expr/mod.rs:464:5 clippy::missing_pa target/lintcheck/sources/cfg-expr-0.7.1/src/expr/mod.rs:57:13 clippy::enum_glob_use "usage of wildcard import for enum variants" target/lintcheck/sources/cfg-expr-0.7.1/src/expr/mod.rs:586:33 clippy::match_same_arms "this `match` has identical arm bodies" target/lintcheck/sources/cfg-expr-0.7.1/src/expr/mod.rs:599:32 clippy::match_same_arms "this `match` has identical arm bodies" +target/lintcheck/sources/cfg-expr-0.7.1/src/expr/mod.rs:609:9 clippy::manual_map "manual implementation of `Option::map`" target/lintcheck/sources/cfg-expr-0.7.1/src/expr/parser.rs:116:31 clippy::similar_names "binding's name is too similar to existing binding" target/lintcheck/sources/cfg-expr-0.7.1/src/expr/parser.rs:124:36 clippy::similar_names "binding's name is too similar to existing binding" target/lintcheck/sources/cfg-expr-0.7.1/src/expr/parser.rs:17:5 clippy::missing_errors_doc "docs for function returning `Result` missing `# Errors` section" @@ -3509,6 +3512,7 @@ clippy::filter_map_next 3 clippy::fn_params_excessive_bools 3 clippy::if_same_then_else 3 clippy::inconsistent_struct_constructor 3 +clippy::manual_map 3 clippy::mut_mut 3 clippy::ptr_arg 3 clippy::zero_ptr 3