revme/
dir_utils.rs

1use std::path::{Path, PathBuf};
2use walkdir::{DirEntry, WalkDir};
3
4/// Find all JSON test files in the given path.
5/// If path is a file, returns it in a vector.
6/// If path is a directory, recursively finds all .json files.
7pub fn find_all_json_tests(path: &Path) -> Vec<PathBuf> {
8    if path.is_file() {
9        vec![path.to_path_buf()]
10    } else {
11        WalkDir::new(path)
12            .into_iter()
13            .filter_map(Result::ok)
14            .filter(|e| e.path().extension() == Some("json".as_ref()))
15            .map(DirEntry::into_path)
16            .collect()
17    }
18}