summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-24 10:36:25 +0300
committerPaul Buetow <paul@buetow.org>2026-06-24 10:36:25 +0300
commit6dfc0f1a9521cc4afe4941fc1328eec014b760a7 (patch)
tree4303307c104aa9dbe84e906eb9c0f1dd279469d9 /tests
parent99c5241d853daceb8cfaec91023730ff062858b7 (diff)
Promote single canonical identify-stream EXIF parser into metadata-cache (8r0)
The `identify -verbose` EXIF-line regex and its array-fill loop were duplicated in three places that had already drifted: album-metadata's photo_exif_details_html and _photo_exif_values_to (exif: only) and stats-aggregate's _stats_parse_identify_stream (exif: plus a native Geometry -> __geometry path). Promote one canonical parser, photo_exif_values_to, into metadata-cache.source.sh next to its sibling cache primitive cached_photo_identify_output. It reads an identify stream from stdin and fills a nameref associative array; it is a strict superset of all three former sites (bare exif: tag keys plus the synthetic __geometry key). - stats accumulate_photo_stats now calls photo_exif_values_to (stdin); _stats_parse_identify_stream is removed. - album _photo_exif_values_to is a thin wrapper that pipes cached_photo_identify_output through the canonical parser. - album photo_exif_details_html consumes the same parser and skips the __geometry key it does not display. metadata-cache is sourced before both consumers in LIB_SOURCES, so the canonical parser is available at use time. Regenerated bin/shuriken via `just build`. Added test_shared_identify_parser_returns_exif_and_geometry asserting one parse yields both an exif: key and __geometry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/cli.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/cli.sh b/tests/cli.sh
index 320ab7e..eae2f19 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -6151,6 +6151,35 @@ test_stats_tolerates_missing_and_edge_case_fields() {
test::teardown
}
+# Regression for 8r0: the single canonical parser (photo_exif_values_to in
+# metadata-cache.source.sh, now shared by album-metadata and stats-aggregate)
+# must be a strict superset of the three former copies -- it returns both the
+# bare exif: tag keys the album relies on AND the synthetic __geometry key the
+# stats dimensions recorder relies on, from one parse of one stdin stream.
+test_shared_identify_parser_returns_exif_and_geometry() {
+ local fixture
+ local -A values=()
+
+ test::setup
+ test::source_shuriken_lib
+
+ fixture=$' Geometry: 160x90+0+0\n'
+ fixture+=$' exif:Make: Canon\n'
+ fixture+=$' exif:FNumber: 28/10'
+
+ photo_exif_values_to values <<< "$fixture"
+
+ # exif: tags are keyed WITHOUT the "exif:" prefix (album/stats convention).
+ test "${values[Make]}" = 'Canon'
+ test "${values[FNumber]}" = '28/10'
+ # The native Geometry line is captured under the synthetic __geometry key.
+ test "${values[__geometry]}" = '160x90+0+0'
+ # Exactly the three recognised fields, nothing spurious.
+ test "${#values[@]}" -eq 3
+
+ test::teardown
+}
+
test_stats_distinct_cameras_get_unique_slugs() {
local sep
test::setup
@@ -6769,6 +6798,9 @@ main() {
'stats tolerate missing and edge-case fields' \
test_stats_tolerates_missing_and_edge_case_fields
test::run_case \
+ 'shared identify parser returns exif and geometry' \
+ test_shared_identify_parser_returns_exif_and_geometry
+ test::run_case \
'stats give distinct cameras unique slugs' \
test_stats_distinct_cameras_get_unique_slugs
test::run_case \