html5ever_test_util/
lib.rs1use std::fs;
11use std::ffi::OsStr;
12use std::path::Path;
13use std::ops::FnMut;
14
15pub fn foreach_html5lib_test<Mk>(
16 src_dir: &Path,
17 subdir: &'static str,
18 ext: &'static OsStr,
19 mut mk: Mk)
20 where Mk: FnMut(&Path, fs::File)
21{
22 let mut test_dir_path = src_dir.to_path_buf();
23 test_dir_path.push("html5lib-tests");
24 test_dir_path.push(subdir);
25
26 let test_files = fs::read_dir(&test_dir_path).unwrap();
27 for entry in test_files {
28 let path = entry.unwrap().path();
29 if path.extension() == Some(ext) {
30 let file = fs::File::open(&path).unwrap();
31 mk(&path, file);
32 }
33 }
34}