diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /vendor/sysinfo/tests/code_checkers | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/sysinfo/tests/code_checkers')
-rw-r--r-- | vendor/sysinfo/tests/code_checkers/docs.rs | 3 | ||||
-rw-r--r-- | vendor/sysinfo/tests/code_checkers/headers.rs | 3 | ||||
-rw-r--r-- | vendor/sysinfo/tests/code_checkers/utils.rs | 16 |
3 files changed, 14 insertions, 8 deletions
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<P: AsRef<Path>, 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<P: AsRef<Path>, F: FnMut(&Path, &str)>(dir: P, callback: &mut F) { } fn read_file<P: AsRef<Path>>(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 } |