diff --git a/crates/ledger-store/tests/spec_store.rs b/crates/ledger-store/tests/spec_store.rs index 447724b..5f13dca 100644 --- a/crates/ledger-store/tests/spec_store.rs +++ b/crates/ledger-store/tests/spec_store.rs @@ -125,13 +125,28 @@ fn line_types(dir: &Path) -> Vec { .collect() } -/// Every file under `dir` (relative path → bytes). +/// Whether `p` is the live SQLite database or one of its companions. +fn is_live_database(p: &Path) -> bool { + let name = p.file_name().unwrap().to_string_lossy().into_owned(); + let db = db_file(); + name == db + || ["-wal", "-shm", "-journal"] + .iter() + .any(|x| name == format!("{db}{x}")) +} + +/// Every file under `dir` (relative path → bytes), the live database and +/// its companions left out. fn tree(dir: &Path) -> BTreeMap> { fn walk(root: &Path, d: &Path, out: &mut BTreeMap>) { for e in std::fs::read_dir(d).unwrap() { let p = e.unwrap().path(); if p.is_dir() { walk(root, &p, out); + } else if p.parent() == Some(root) && is_live_database(&p) { + // An open SQLite connection holds byte-range locks on its + // database file on Windows: a plain read is refused. The + // tests compare the journal, blobs and kept-aside files. } else { out.insert( p.strip_prefix(root).unwrap().to_path_buf(),