mod errors; mod locations; mod parsing; fn do_tests_in_dir( dir: &str, ext: &str, test: impl Fn(&str) -> Result<(), Box>, ) { let result = (|| -> Result<(), Box> { 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}")) .map_err(|e| format!("{dir}/{filename}: {e}"))?; } } Ok(()) })(); if let Err(e) = result { panic!("Error: {e}"); } }