tidy: Fix a regression in #[test] detection in libcore

`contents` is the whole file rather than a single line.
This commit is contained in:
Vadim Petrochenkov 2019-07-26 01:22:59 +03:00
parent c0df742de8
commit 6a4def0c9d

View file

@ -13,14 +13,16 @@ pub fn check(path: &Path, bad: &mut bool) {
&mut |entry, contents| {
let subpath = entry.path();
if let Some("rs") = subpath.extension().and_then(|e| e.to_str()) {
let contents = contents.trim();
if !contents.starts_with("//") && contents.contains("#[test]") {
tidy_error!(
bad,
"`{}` contains `#[test]`; libcore tests must be placed inside \
`src/libcore/tests/`",
subpath.display()
);
for line in contents.lines() {
let line = line.trim();
if !line.starts_with("//") && line.contains("#[test]") {
tidy_error!(
bad,
"`{}` contains `#[test]`; libcore tests must be placed inside \
`src/libcore/tests/`",
subpath.display()
);
}
}
}
},