Skip to content

Commit 346ca3c

Browse files
committed
lintcheck: add small test that runs lintcheck on 3 crates
1 parent 77e3bc4 commit 346ca3c

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

clippy_dev/ci_test_sources.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[crates]
2+
cc = {name = "cc", versions = ['1.0.67']}
3+
home = {name = "home", git_url = "https://github.com/brson/home", git_hash = "32044e53dfbdcd32bafad3109d1fbab805fc0f40"}
4+
rustc_tools_util = {name = "rustc_tools_util", versions = ['0.2.0']}

clippy_dev/src/lintcheck.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,9 @@ fn gather_stats(clippy_warnings: &[ClippyWarning]) -> (String, HashMap<&String,
501501
/// check if the latest modification of the logfile is older than the modification date of the
502502
/// clippy binary, if this is true, we should clean the lintchec shared target directory and recheck
503503
fn lintcheck_needs_rerun(lintcheck_logs_path: &Path) -> bool {
504+
if !lintcheck_logs_path.exists() {
505+
return true;
506+
}
504507
let clippy_modified: std::time::SystemTime = {
505508
let mut times = [CLIPPY_DRIVER_PATH, CARGO_CLIPPY_PATH].iter().map(|p| {
506509
std::fs::metadata(p)
@@ -663,7 +666,6 @@ fn read_stats_from_file(file_path: &Path) -> HashMap<String, usize> {
663666
let file_content: String = match std::fs::read_to_string(file_path).ok() {
664667
Some(content) => content,
665668
None => {
666-
eprintln!("RETURND");
667669
return HashMap::new();
668670
},
669671
};
@@ -732,3 +734,32 @@ fn print_stats(old_stats: HashMap<String, usize>, new_stats: HashMap<&String, us
732734
println!("{} {} => 0", old_key, old_value);
733735
});
734736
}
737+
738+
#[test]
739+
fn lintcheck_test() {
740+
let args = [
741+
"run",
742+
"--target-dir",
743+
"clippy_dev/target",
744+
"--package",
745+
"clippy_dev",
746+
"--bin",
747+
"clippy_dev",
748+
"--manifest-path",
749+
"clippy_dev/Cargo.toml",
750+
"--features",
751+
"lintcheck",
752+
"--",
753+
"lintcheck",
754+
//"--",
755+
"--crates-toml",
756+
//"--",
757+
"clippy_dev/ci_test_sources.toml",
758+
];
759+
let status = std::process::Command::new("cargo")
760+
.args(&args)
761+
.current_dir("../" /* repo root */)
762+
.status();
763+
764+
assert!(status.unwrap().success());
765+
}

0 commit comments

Comments
 (0)