mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
lintcheck: add test
This commit is contained in:
parent
7be3a32f25
commit
37c4b11a84
2 changed files with 35 additions and 1 deletions
|
@ -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<String, usize> {
|
|||
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<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
clippy_dev/test_sources.toml
Normal file
4
clippy_dev/test_sources.toml
Normal file
|
@ -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']}
|
Loading…
Reference in a new issue