mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +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 walkdir::WalkDir;
|
||||||
|
|
||||||
|
use clippy_dev::clippy_project_root;
|
||||||
|
|
||||||
// The maximum length allowed for stderr files.
|
// The maximum length allowed for stderr files.
|
||||||
//
|
//
|
||||||
// We limit this because small files are easier to deal with than bigger 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() {
|
if !exceeding_files.is_empty() {
|
||||||
eprintln!("Error: stderr files exceeding limit of {} lines:", LENGTH_LIMIT);
|
eprintln!("Error: stderr files exceeding limit of {} lines:", LENGTH_LIMIT);
|
||||||
for path in exceeding_files {
|
for (path, count) in exceeding_files {
|
||||||
println!("{}", path.display());
|
println!("{}: {}", path.display(), count);
|
||||||
}
|
}
|
||||||
std::process::exit(1);
|
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.
|
// 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()
|
.into_iter()
|
||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
|
.filter(|f| !f.file_type().is_dir())
|
||||||
.filter_map(|e| {
|
.filter_map(|e| {
|
||||||
let p = e.into_path();
|
let p = e.into_path();
|
||||||
if p.extension() == Some(OsStr::new("stderr")) && count_linenumbers(&p) > LENGTH_LIMIT {
|
let count = count_linenumbers(&p);
|
||||||
Some(p)
|
if p.extension() == Some(OsStr::new("stderr")) && count > LENGTH_LIMIT {
|
||||||
|
Some((p, count))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue