From 8760dc4a414154f5adeef15e8e2bfde5881b79d6 Mon Sep 17 00:00:00 2001 From: Alfons Hoogervorst <92640+snofla@users.noreply.github.com> Date: Sun, 11 Oct 2026 17:21:31 +0200 Subject: [PATCH] Issue #989: odd_folders_never_fail_the_check skips its non-UTF-8 names where the file system refuses them (item 3, one of eleven) APFS refuses names that are not valid UTF-8 (EILSEQ, os error 92), so the test's create_dir_all(...).unwrap() panicked on macOS. The test now probes once with a \xff folder; where that fails, the non-UTF-8 folder case and the non-UTF-8 entry are skipped and the catalog-folder and symlink cases still run on a plain-named folder. Where the probe succeeds (Linux, FreeBSD) the test is unchanged. Run on macOS (case-insensitive APFS, rustc 1.99.0): the five tests in tests_lightroom_folder pass, cargo fmt is clean, and clippy over lightcraft-engine with --all-targets is clean. The ten sidecar tests of item 3 are not touched. Co-Authored-By: Claude Sonnet 5.5 --- crates/engine/src/tests_lightroom_folder.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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