1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::path::{Path, PathBuf};
pub fn iterate_directory(path: &Path) -> impl Iterator<Item = PathBuf> {
walkdir::WalkDir::new(path)
.into_iter()
.map(::std::result::Result::unwrap)
.filter(|entry| {
entry.file_type().is_file()
&& entry
.file_name()
.to_str()
.map_or(false, |s| !s.starts_with('.'))
})
.map(|entry| entry.path().to_path_buf())
}
pub fn derive_test_name(root: &Path, path: &Path, test_name: &str) -> String {
let relative = path.strip_prefix(root).unwrap_or_else(|_| {
panic!(
"failed to strip prefix '{}' from path '{}'",
root.display(),
path.display()
)
});
let mut test_name = test_name.to_string();
test_name.push_str(&format!("::{}", relative.display()));
test_name
}