From d1b2d29528b7794b41e66fc2136e395a02f8529b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:35 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/sysinfo/tests/code_checkers/docs.rs | 3 +-- vendor/sysinfo/tests/code_checkers/headers.rs | 3 +-- vendor/sysinfo/tests/code_checkers/utils.rs | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'vendor/sysinfo/tests/code_checkers') diff --git a/vendor/sysinfo/tests/code_checkers/docs.rs b/vendor/sysinfo/tests/code_checkers/docs.rs index 7720d2dcf..4cfdadfd3 100644 --- a/vendor/sysinfo/tests/code_checkers/docs.rs +++ b/vendor/sysinfo/tests/code_checkers/docs.rs @@ -38,8 +38,7 @@ fn check_md_doc_path(p: &Path, md_line: &str, ty_line: &str) -> bool { show_error( p, &format!( - "Invalid markdown file name `{}`, should have been `{}`", - md_name, correct + "Invalid markdown file name `{md_name}`, should have been `{correct}`", ), ); return false; diff --git a/vendor/sysinfo/tests/code_checkers/headers.rs b/vendor/sysinfo/tests/code_checkers/headers.rs index d66aa4202..081df8fee 100644 --- a/vendor/sysinfo/tests/code_checkers/headers.rs +++ b/vendor/sysinfo/tests/code_checkers/headers.rs @@ -39,8 +39,7 @@ pub fn check_license_header(content: &str, p: &Path) -> TestResult { show_error( p, &format!( - "Expected license header at the top of the file (`{}`), found: `{}`", - header, s + "Expected license header at the top of the file (`{header}`), found: `{s}`", ), ); TestResult { diff --git a/vendor/sysinfo/tests/code_checkers/utils.rs b/vendor/sysinfo/tests/code_checkers/utils.rs index 893201961..159b30d36 100644 --- a/vendor/sysinfo/tests/code_checkers/utils.rs +++ b/vendor/sysinfo/tests/code_checkers/utils.rs @@ -28,7 +28,11 @@ fn read_dir, F: FnMut(&Path, &str)>(dir: P, callback: &mut F) { let path = entry.path(); if path.is_dir() { read_dir(path, callback); - } else { + } else if path + .extension() + .map(|ext| ext == "rs" || ext == "c" || ext == "h") + .unwrap_or(false) + { let content = read_file(&path); callback(&path, &content); } @@ -36,11 +40,15 @@ fn read_dir, F: FnMut(&Path, &str)>(dir: P, callback: &mut F) { } fn read_file>(p: P) -> String { - let mut f = File::open(p).expect("read_file::open failed"); + let mut f = File::open(&p).expect("read_file::open failed"); let mut content = String::with_capacity(f.metadata().map(|m| m.len() as usize + 1).unwrap_or(0)); - f.read_to_string(&mut content) - .expect("read_file::read_to_end failed"); + if let Err(e) = f.read_to_string(&mut content) { + panic!( + "read_file::read_to_end failed for `{}: {e:?}", + p.as_ref().display() + ); + } content } -- cgit v1.2.3