Skip to content

Commit bd44177

Browse files
varkorMark-Simulacrum
authored andcommitted
Display the name of the failed file in tidy/libcoretest
1 parent ae41d6c commit bd44177

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/tools/tidy/src/libcoretest.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ 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 subpath.ends_with(".rs") {
26-
if t!(read_to_string(subpath)).contains("#[test]") {
27-
tidy_error!(
28-
bad,
29-
"{} contains #[test]; libcore tests must be placed inside \
30-
`src/libcore/tests/`",
31-
subpath.display()
32-
);
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+
}
3340
}
3441
}
3542
},

0 commit comments

Comments
 (0)