Skip to content

Commit a37bb08

Browse files
authored
Rollup merge of rust-lang#50661 - varkor:libcoretest-ignore-non-rs, r=alexcrichton
Ignore non .rs files for tidy libcoretest Previously, any file would be read, which is both unnecessary, and causes issues if irrelevant non-Unicode files were read (e.g. `.DS_STORE`).
2 parents 73c7528 + 16c088d commit a37bb08

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/tools/tidy/src/libcoretest.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ pub fn check(path: &Path, bad: &mut bool) {
2222
&libcore_path,
2323
&mut |subpath| t!(subpath.strip_prefix(&libcore_path)).starts_with("tests"),
2424
&mut |subpath| {
25-
if t!(read_to_string(subpath)).contains("#[test]") {
26-
tidy_error!(
27-
bad,
28-
"{} contains #[test]; libcore tests must be placed inside `src/libcore/tests/`",
29-
subpath.display()
30-
);
25+
if let Some("rs") = subpath.extension().and_then(|e| e.to_str()) {
26+
match read_to_string(subpath) {
27+
Ok(contents) => {
28+
if contents.contains("#[test]") {
29+
tidy_error!(
30+
bad,
31+
"{} contains #[test]; libcore tests must be placed inside \
32+
`src/libcore/tests/`",
33+
subpath.display()
34+
);
35+
}
36+
}
37+
Err(err) => {
38+
panic!("failed to read file {:?}: {}", subpath, err);
39+
}
40+
}
3141
}
3242
},
3343
);

0 commit comments

Comments
 (0)