]> git.lizzy.rs Git - rust.git/commitdiff
tidy: libcoretest.rs -> unit_tests.rs
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Thu, 25 Jul 2019 22:18:35 +0000 (01:18 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 27 Jul 2019 14:26:55 +0000 (17:26 +0300)
src/tools/tidy/src/lib.rs
src/tools/tidy/src/libcoretest.rs [deleted file]
src/tools/tidy/src/main.rs
src/tools/tidy/src/unit_tests.rs [new file with mode: 0644]

index 06c1a8c18bac7b7e323a24754ff154879504a66b..3d40bdced63e069705107bff7bf51c0db5b76868 100644 (file)
@@ -38,8 +38,8 @@ macro_rules! tidy_error {
 pub mod deps;
 pub mod extdeps;
 pub mod ui_tests;
+pub mod unit_tests;
 pub mod unstable_book;
-pub mod libcoretest;
 
 fn filter_dirs(path: &Path) -> bool {
     let skip = [
diff --git a/src/tools/tidy/src/libcoretest.rs b/src/tools/tidy/src/libcoretest.rs
deleted file mode 100644 (file)
index 579a20e..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-//! Tidy check to ensure `#[test]` is not used directly inside `libcore`.
-//!
-//! `#![no_core]` libraries cannot be tested directly due to duplicating lang
-//! item. All tests must be written externally in `libcore/tests`.
-
-use std::path::Path;
-
-pub fn check(path: &Path, bad: &mut bool) {
-    let libcore_path = path.join("libcore");
-    super::walk(
-        &libcore_path,
-        &mut |subpath| t!(subpath.strip_prefix(&libcore_path)).starts_with("tests"),
-        &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()
-                    );
-                }
-            }
-        },
-    );
-}
index 918762ed6e69a20217fdaae89681d4cc388980ae..19f02f0a96e1da029667269280fc38189c0c6645 100644 (file)
@@ -27,7 +27,7 @@ fn main() {
     let collected = features::check(&path, &mut bad, verbose);
     pal::check(&path, &mut bad);
     unstable_book::check(&path, collected, &mut bad);
-    libcoretest::check(&path, &mut bad);
+    unit_tests::check(&path, &mut bad);
     if !args.iter().any(|s| *s == "--no-vendor") {
         deps::check(&path, &mut bad);
     }
diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs
new file mode 100644 (file)
index 0000000..579a20e
--- /dev/null
@@ -0,0 +1,28 @@
+//! Tidy check to ensure `#[test]` is not used directly inside `libcore`.
+//!
+//! `#![no_core]` libraries cannot be tested directly due to duplicating lang
+//! item. All tests must be written externally in `libcore/tests`.
+
+use std::path::Path;
+
+pub fn check(path: &Path, bad: &mut bool) {
+    let libcore_path = path.join("libcore");
+    super::walk(
+        &libcore_path,
+        &mut |subpath| t!(subpath.strip_prefix(&libcore_path)).starts_with("tests"),
+        &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()
+                    );
+                }
+            }
+        },
+    );
+}