blob: 83873dc4b3e57b8cd9c8d7a03345198179cc3f36 (
plain)
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
|
mod locations;
mod parsing;
fn do_tests_in_dir(
dir: &str,
ext: &str,
test: impl Fn(&str) -> Result<(), Box<dyn std::error::Error>>,
) {
let result = (|| -> Result<(), Box<dyn std::error::Error>> {
let test_dir = format!("../tests/{dir}");
let tests = std::fs::read_dir(&test_dir).map_err(|e| {
format!(
"error reading {test_dir}: {e} — try moving pom-rs to inside the main pom repository?"
)
})?;
for test_entry in tests {
let filename = test_entry
.map_err(|e| format!("error reading tests directory {test_dir}: {e}"))?
.file_name()
.into_string()
.expect("bad UTF-8 in test name (file in {test_dir})");
if filename.ends_with(ext) {
println!("Running test {dir}/{filename}...");
test(&format!("{test_dir}/{filename}"))?
}
}
Ok(())
})();
if let Err(e) = result {
panic!("Error: {e}");
}
}
|