From 6a4def0c9df85649336a52607347f613efcca918 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 26 Jul 2019 01:22:59 +0300 Subject: [PATCH] tidy: Fix a regression in `#[test]` detection in libcore `contents` is the whole file rather than a single line. --- src/tools/tidy/src/unit_tests.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index 579a20e1142b..6c61144f2793 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -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() + ); + } } } },