diff --git a/crates/engine/src/tests_lightroom_folder.rs b/crates/engine/src/tests_lightroom_folder.rs index cdf9905c4..eccff23ac 100644 --- a/crates/engine/src/tests_lightroom_folder.rs +++ b/crates/engine/src/tests_lightroom_folder.rs @@ -155,13 +155,22 @@ fn odd_folders_never_fail_the_check() { #[cfg(unix)] { use std::os::unix::ffi::OsStrExt; - let bad = root.join(std::ffi::OsStr::from_bytes(b"caf\xe9 Previews.lrdata")); - std::fs::create_dir_all(&bad).unwrap(); - std::fs::write(root.join("Cat.lrcat"), b"x").unwrap(); - assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: Some(root.join("Cat.lrcat")) }), "non-UTF-8 name"); - let lr = root.join(std::ffi::OsStr::from_bytes(b"\xff\xfe")); + // APFS (macOS) refuses names that are not valid UTF-8 (EILSEQ): there the non-UTF-8 cases are skipped and + // the symlink cases below still run on a plain-named catalog folder + let probe = root.join(std::ffi::OsStr::from_bytes(b"\xff")); + let utf8_only = std::fs::create_dir(&probe).is_err(); + let _ = std::fs::remove_dir(&probe); + if !utf8_only { + let bad = root.join(std::ffi::OsStr::from_bytes(b"caf\xe9 Previews.lrdata")); + std::fs::create_dir_all(&bad).unwrap(); + std::fs::write(root.join("Cat.lrcat"), b"x").unwrap(); + assert_eq!(lightroom_catalog_at(&bad), Some(LightroomPlace { catalog: Some(root.join("Cat.lrcat")) }), "non-UTF-8 name"); + } + let lr = root.join(if utf8_only { std::ffi::OsStr::new("lr") } else { std::ffi::OsStr::from_bytes(b"\xff\xfe") }); std::fs::create_dir_all(&lr).unwrap(); - std::fs::write(lr.join(std::ffi::OsStr::from_bytes(b"\xff.lrcat")), b"x").unwrap(); + if !utf8_only { + std::fs::write(lr.join(std::ffi::OsStr::from_bytes(b"\xff.lrcat")), b"x").unwrap(); + } std::fs::write(lr.join("b.lrcat"), b"x").unwrap(); assert_eq!(lightroom_catalog_at(&lr), Some(LightroomPlace { catalog: Some(lr.join("b.lrcat")) }), "non-UTF-8 entries skipped"); // a symlink to a catalog folder is one too; a dangling one is not