blob: eb98a04e84eb9cab2441b308d3690bbb2a83a49e (
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
33
34
35
36
|
use crate::Configuration;
static TEST_DIR: &str = "../tests/parsing";
fn single_test(flat_name: &str, complex_name: &str) -> Result<(), Box<dyn std::error::Error>> {
println!("Running test {complex_name}...");
let config1 = Configuration::load_path(format!("{TEST_DIR}/{flat_name}"))?;
let config2 = Configuration::load_path(format!("{TEST_DIR}/{complex_name}"))?;
super::check_configs_equal(&config1, &config2)
}
fn try_parsing() -> Result<(), Box<dyn std::error::Error>> {
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(".flat.pom") {
single_test(&filename, filename.replace(".flat.pom", ".pom").as_ref())?;
}
}
Ok(())
}
#[test]
fn parsing() {
if let Err(e) = try_parsing() {
panic!("Error: {e}");
}
}
|