mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Fix limit-stderr-files test
This commit is contained in:
parent
a808779441
commit
f041dcdb4e
1 changed files with 10 additions and 6 deletions
|
@ -4,6 +4,8 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use clippy_dev::clippy_project_root;
|
||||
|
||||
// The maximum length allowed for stderr files.
|
||||
//
|
||||
// We limit this because small files are easier to deal with than bigger files.
|
||||
|
@ -14,22 +16,24 @@ pub fn check() {
|
|||
|
||||
if !exceeding_files.is_empty() {
|
||||
eprintln!("Error: stderr files exceeding limit of {} lines:", LENGTH_LIMIT);
|
||||
for path in exceeding_files {
|
||||
println!("{}", path.display());
|
||||
for (path, count) in exceeding_files {
|
||||
println!("{}: {}", path.display(), count);
|
||||
}
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn exceeding_stderr_files() -> Vec<PathBuf> {
|
||||
fn exceeding_stderr_files() -> Vec<(PathBuf, usize)> {
|
||||
// We use `WalkDir` instead of `fs::read_dir` here in order to recurse into subdirectories.
|
||||
WalkDir::new("../tests/ui")
|
||||
WalkDir::new(clippy_project_root().join("tests/ui"))
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
.filter(|f| !f.file_type().is_dir())
|
||||
.filter_map(|e| {
|
||||
let p = e.into_path();
|
||||
if p.extension() == Some(OsStr::new("stderr")) && count_linenumbers(&p) > LENGTH_LIMIT {
|
||||
Some(p)
|
||||
let count = count_linenumbers(&p);
|
||||
if p.extension() == Some(OsStr::new("stderr")) && count > LENGTH_LIMIT {
|
||||
Some((p, count))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue