Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

test(format): skip the bundle-lock test only where file locks are unsupported

Finn Newicke795cabc7981
diff --git a/crates/format/tests/roundtrip.rs b/crates/format/tests/roundtrip.rs
index 3f3275589..6f7066159 100644
--- a/crates/format/tests/roundtrip.rs
+++ b/crates/format/tests/roundtrip.rs
@@ -738,7 +738,13 @@ fn directory_save_waits_for_the_bundle_lock() {
let doc = rich_doc(ColorMode::Rgb, SampleType::U8);
let dir = temp_dir("lock");
let other = std::fs::OpenOptions::new().read(true).write(true).create(true).truncate(false).open(dir.join("save.lock")).unwrap();
- other.lock().unwrap();
+ // A file system without file locks saves unlocked (`lock_bundle`), so there's nothing to test.
+ match other.try_lock() {
+ Ok(()) => {}
+ Err(std::fs::TryLockError::Error(e)) if e.kind() == std::io::ErrorKind::Unsupported => return,
+ Err(std::fs::TryLockError::Error(e)) => panic!("locking save.lock failed: {e}"),
+ Err(std::fs::TryLockError::WouldBlock) => panic!("save.lock is already locked"),
+ }
let mut w = PcraftWriter::new();
w.set_lock_wait(std::time::Duration::from_millis(100));
let e = w.save_dir(&doc, &dir, &SaveOptions::default()).unwrap_err();