]> git.lizzy.rs Git - rust.git/blobdiff - tests/missing-test-files.rs
Special sync of 'e89801553ddbaccdeb2eac4db08900edb51ac7ff'
[rust.git] / tests / missing-test-files.rs
index f79abedc062af762b660334720c8e585d93f2fdd..d87bb4be3c3f976e26e94ddfad4135d6993cf45d 100644 (file)
@@ -1,10 +1,12 @@
+#![allow(clippy::assertions_on_constants)]
+
 use std::fs::{self, DirEntry};
 use std::path::Path;
 
 #[test]
 fn test_missing_tests() {
     let missing_files = explore_directory(Path::new("./tests"));
-    if missing_files.len() > 0 {
+    if !missing_files.is_empty() {
         assert!(
             false,
             format!(
@@ -30,26 +32,23 @@ fn explore_directory(dir: &Path) -> Vec<String> {
     let mut missing_files: Vec<String> = Vec::new();
     let mut current_file = String::new();
     let mut files: Vec<DirEntry> = fs::read_dir(dir).unwrap().filter_map(Result::ok).collect();
-    files.sort_by_key(|e| e.path());
-    for entry in files.iter() {
+    files.sort_by_key(std::fs::DirEntry::path);
+    for entry in &files {
         let path = entry.path();
         if path.is_dir() {
             missing_files.extend(explore_directory(&path));
         } else {
             let file_stem = path.file_stem().unwrap().to_str().unwrap().to_string();
-            match path.extension() {
-                Some(ext) => {
-                    match ext.to_str().unwrap() {
-                        "rs" => current_file = file_stem.clone(),
-                        "stderr" | "stdout" => {
-                            if file_stem != current_file {
-                                missing_files.push(path.to_str().unwrap().to_string());
-                            }
-                        },
-                        _ => continue,
-                    };
-                },
-                None => {},
+            if let Some(ext) = path.extension() {
+                match ext.to_str().unwrap() {
+                    "rs" => current_file = file_stem.clone(),
+                    "stderr" | "stdout" => {
+                        if file_stem != current_file {
+                            missing_files.push(path.to_str().unwrap().to_string());
+                        }
+                    },
+                    _ => continue,
+                };
             }
         }
     }