Files
Liber-public/crates/liber-format/tests/corpus.rs
T

20 lines
908 B
Rust

//! Opens every file `fixtures-fetch/fetch.mjs` put in `fixtures/fetched/` (none by default): no panic, bounded
//! time, nothing active or remote in the output.
#[test]
fn fetched_corpus() {
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/fetched");
let Ok(entries) = std::fs::read_dir(&dir) else { return };
for e in entries.flatten() {
let bytes = std::fs::read(e.path()).unwrap();
let t = std::time::Instant::now();
if let Ok(d) = liber_format::open(&bytes, e.file_name().to_str(), &liber_format::Limits::default()) {
for c in &d.chapters {
let x = c.xhtml.replacen("http://www.w3.org/1999/xhtml", "", 1);
assert!(!x.contains("<script") && !x.contains("http"), "{}", e.path().display());
}
}
assert!(t.elapsed().as_secs() < 30, "{}", e.path().display());
}
}