about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorUnknown <dobbybabee@gmail.com>2019-01-17 23:50:30 -0500
committerUnknown <dobbybabee@gmail.com>2019-01-17 23:50:30 -0500
commita3b3a54e930dec06935af37beae340a8f6a7b4ec (patch)
tree2ef8413bf5426d18f5550fb9d91c5d19f4a60b2f /tests
parent8b81208012c2d88df74e18579a8025c24305db8c (diff)
Update to collect all the files then throw the error.
Diffstat (limited to 'tests')
-rw-r--r--tests/missing-test-files.rs34
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/missing-test-files.rs b/tests/missing-test-files.rs
index 31d2dccff71..f79abedc062 100644
--- a/tests/missing-test-files.rs
+++ b/tests/missing-test-files.rs
@@ -1,10 +1,22 @@
 use std::fs::{self, DirEntry};
-use std::io;
 use std::path::Path;
 
 #[test]
 fn test_missing_tests() {
-    explore_directory(Path::new("./tests")).unwrap();
+    let missing_files = explore_directory(Path::new("./tests"));
+    if missing_files.len() > 0 {
+        assert!(
+            false,
+            format!(
+                "Didn't see a test file for the following files:\n\n{}\n",
+                missing_files
+                    .iter()
+                    .map(|s| format!("\t{}", s))
+                    .collect::<Vec<_>>()
+                    .join("\n")
+            )
+        );
+    }
 }
 
 /*
@@ -14,14 +26,15 @@ Since rs files are alphabetically before stderr/stdout, we can sort by the full
 and iter in that order. If we've seen the file stem for the first time and it's not
 a rust file, it means the rust file has to be missing.
 */
-fn explore_directory(dir: &Path) -> io::Result<()> {
+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)?.filter_map(Result::ok).collect();
+    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() {
         let path = entry.path();
         if path.is_dir() {
-            explore_directory(&path)?;
+            missing_files.extend(explore_directory(&path));
         } else {
             let file_stem = path.file_stem().unwrap().to_str().unwrap().to_string();
             match path.extension() {
@@ -29,12 +42,9 @@ fn explore_directory(dir: &Path) -> io::Result<()> {
                     match ext.to_str().unwrap() {
                         "rs" => current_file = file_stem.clone(),
                         "stderr" | "stdout" => {
-                            assert_eq!(
-                                file_stem,
-                                current_file,
-                                "{}",
-                                format!("Didn't see a test file for {:}", path.to_str().unwrap())
-                            );
+                            if file_stem != current_file {
+                                missing_files.push(path.to_str().unwrap().to_string());
+                            }
                         },
                         _ => continue,
                     };
@@ -43,5 +53,5 @@ fn explore_directory(dir: &Path) -> io::Result<()> {
             }
         }
     }
-    Ok(())
+    missing_files
 }