diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-16 23:00:23 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-16 23:00:23 +0300 |
| commit | 72f72995a9c4a1ddd2ea3adb04cc2d7641410245 (patch) | |
| tree | 7a0ffba9dedf0c205dc22c9ac77b52a5eff127b9 /tests/helpers.sh | |
| parent | 0eccf41ff404029bd6f39f06b0a14f1643ddbdda (diff) | |
9n0 warn on identify failure instead of caching empty EXIF
cached_photo_identify_output() swallowed all ImageMagick errors with
'imagemagick_identify ... || true', so a corrupt photo or identify
failure left the cache with only the signature line and no EXIF. That
signature-only file was a valid-looking cache hit, so the photo rendered
with empty tooltip/stats and the failure was never retried or warned
about again.
Now capture identify's exit status; on failure, log_warning naming the
photo and rm -f the cache file so the next run retries instead of
reusing an empty result. The function still returns 0 so one unreadable
photo does not abort generation (it runs in backgrounded render jobs
under set -euo pipefail) -- the photo just renders without EXIF, now
with a warning.
Adds tests/cli.sh test_generate_warns_and_skips_cache_on_identify_failure
and a TEST_IMAGEMAGICK_IDENTIFY_FAIL hook in the fake ImageMagick to
drive a failing identify; asserts exit 0, a warning naming the photo,
the photo still rendered, and that the failed photo's cache is absent
while a successful photo's cache is present.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests/helpers.sh')
| -rwxr-xr-x | tests/helpers.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/helpers.sh b/tests/helpers.sh index d2d6605..477acfc 100755 --- a/tests/helpers.sh +++ b/tests/helpers.sh @@ -196,6 +196,17 @@ if [ "${1:-}" = identify ]; then if [ -n "${TEST_IMAGEMAGICK_IDENTIFY_LOG:-}" ]; then printf '%s\n' "$*" >> "$TEST_IMAGEMAGICK_IDENTIFY_LOG" fi + # Simulate a corrupt photo / identify failure when the fixture matches the + # configured failing target (or "*" for any photo). Emit an error to stderr + # and exit non-zero so callers can exercise the failure path. + if [ -n "${TEST_IMAGEMAGICK_IDENTIFY_FAIL:-}" ]; then + target="${@: -1}" + if [ "$TEST_IMAGEMAGICK_IDENTIFY_FAIL" = '*' ] \ + || [[ "$target" == *"$TEST_IMAGEMAGICK_IDENTIFY_FAIL"* ]]; then + printf 'identify: corrupt image\n' >&2 + exit 1 + fi + fi if [ -n "${TEST_IMAGEMAGICK_IDENTIFY_OUTPUT:-}" ]; then printf '%s\n' "$TEST_IMAGEMAGICK_IDENTIFY_OUTPUT" fi |
