From f041dcdb4e47b01e5a22f86054ad57d42ed17f4a Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 18 Mar 2020 15:27:25 +0100 Subject: Fix limit-stderr-files test --- clippy_dev/src/stderr_length_check.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'clippy_dev') diff --git a/clippy_dev/src/stderr_length_check.rs b/clippy_dev/src/stderr_length_check.rs index 041ee691137..c511733f7bf 100644 --- a/clippy_dev/src/stderr_length_check.rs +++ b/clippy_dev/src/stderr_length_check.rs @@ -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 { +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 } -- cgit 1.4.1-3-g733a5