Skip to content

Commit

Permalink
Auto merge of #6846 - matthiaskrgr:lintcheck_test, r=Manishearth
Browse files Browse the repository at this point in the history
lintcheck: add test (but don't run on ci)

This is the rest of #6829 but without adding anything to ci

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: none
  • Loading branch information
bors committed Mar 4, 2021
2 parents 7be3a32 + 3f7ad32 commit f0e6ce8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
32 changes: 31 additions & 1 deletion clippy_dev/src/lintcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -665,7 +669,6 @@ fn read_stats_from_file(file_path: &Path) -> HashMap<String, usize> {
let file_content: String = match std::fs::read_to_string(file_path).ok() {
Some(content) => content,
None => {
eprintln!("RETURND");
return HashMap::new();
},
};
Expand Down Expand Up @@ -734,3 +737,30 @@ fn print_stats(old_stats: HashMap<String, usize>, 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());
}
4 changes: 4 additions & 0 deletions clippy_dev/test_sources.toml
Original file line number Diff line number Diff line change
@@ -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']}
6 changes: 5 additions & 1 deletion lintcheck-logs/lintcheck_crates_logs.txt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f0e6ce8

Please sign in to comment.