tidy: Fix a regression in #[test] detection in libcore
`contents` is the whole file rather than a single line.
This commit is contained in:
parent
c0df742de8
commit
6a4def0c9d
1 changed files with 10 additions and 8 deletions
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue