diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-28 09:19:33 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-28 09:19:33 +0300 |
| commit | 86c354932e698d52f23e65a1dafb1b7250f4c1b9 (patch) | |
| tree | 2b67fdfab41fab1036c55e91bd2ddf72c25829dd /tests | |
| parent | 94479238557adcab33a95fefbf752a3742b8a8ba (diff) | |
Centralize DIST_DIR-derived paths via working_dir/exif_cache_dir helpers
The EXIF cache dir ($(dirname "$DIST_DIR")/cache/exif) was recomputed inline,
byte for byte, in both cached_photo_identify_output (read/write) and
clear_exif_cache (--force/--clean removal). The plain parent of DIST_DIR
(dirname "$DIST_DIR") was likewise recomputed in metadata-cache and in
action.source.sh's staging-artifact cleanup.
Extract two helpers computed once from DIST_DIR:
- working_dir() in config.source.sh (next to existing_parent_dir, the other
DIST_DIR-parent resolver): plain `dirname "$DIST_DIR"`.
- exif_cache_dir() in metadata-cache.source.sh (owns the EXIF cache):
`working_dir()/cache/exif`.
Route cached_photo_identify_output, clear_exif_cache, and
clean_generation_staging_artifacts through them so the cache reader and the
cleaner can never drift to different directories. Paths are byte-identical to
the prior inline code (dirname semantics, cache/exif suffix, trailing-slash and
relative/absolute handling all preserved). Stale "recompute the cache dir"
comments removed; helpers document the path once. Add a unit test asserting the
helpers agree and resolve beside dist for several DIST_DIR shapes.
Broader DIST_DIR parameterization of leaf pipeline helpers was intentionally
left out of scope (only the duplicated path computation is centralized here).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/cli.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/cli.sh b/tests/cli.sh index 2280a7e..c8cbd36 100755 --- a/tests/cli.sh +++ b/tests/cli.sh @@ -6396,6 +6396,31 @@ test::source_shuriken_lib() { source <(sed '$d' "$TEST_SHURIKEN") } +# pr0: the EXIF cache dir is computed once via exif_cache_dir() (= working_dir()/ +# cache/exif, where working_dir() is dirname "$DIST_DIR"). Both the cache +# reader/writer and the --force/--clean cleaner route through this single helper, +# so they can never point at different directories. Assert the helpers agree and +# resolve to the documented "sibling of dist" path for a few DIST_DIR shapes. +test_exif_cache_dir_resolves_beside_dist() { + test::setup + test::source_shuriken_lib + + DIST_DIR='/home/u/site/dist' + test "$(working_dir)" = '/home/u/site' + test "$(exif_cache_dir)" = '/home/u/site/cache/exif' + + # Relative DIST_DIR keeps dirname semantics (parent is "."). + DIST_DIR='dist' + test "$(working_dir)" = '.' + test "$(exif_cache_dir)" = './cache/exif' + + # A trailing slash is collapsed exactly as dirname collapses it. + DIST_DIR='a/b/dist/' + test "$(exif_cache_dir)" = 'a/b/cache/exif' + + test::teardown +} + test_stats_aggregates_synthetic_exif_fixtures() { local fixture @@ -7188,6 +7213,9 @@ main() { '--generate reuses cached EXIF details unless forced' \ test_generate_reuses_cached_exif_details_unless_forced test::run_case \ + 'EXIF cache dir resolves beside dist' \ + test_exif_cache_dir_resolves_beside_dist + test::run_case \ 'stats aggregate synthetic EXIF fixtures' \ test_stats_aggregates_synthetic_exif_fixtures test::run_case \ |
