Skip to content

Keep one set of golden images - #80

Merged
beetlebugorg merged 1 commit into
mainfrom
test/single-golden-set
Aug 27, 2026
Merged

beetlebugorg merged 1 commit into
mainfrom
test/single-golden-set

Conversation

@beetlebugorg

Copy link
Copy Markdown
Owner

Golden images were keyed by platform, as grid.TestCrop-linux-alpine_amd64.golden.png. They are now just grid.TestCrop.golden.png.

The suffix was not earning its place

Comparing every pair that existed on both architectures:

13 identical
 3 differ

The three that differ are TestRotate90, TestRotate180, and TestRotate270, and they differ because the arm64 files are stale rather than because the architecture matters. #66 replaced Similarity with vips.Rotate for quarter turns and only the amd64 baselines were regenerated. TestRotate180 on arm64 is 6887 bytes, which is exactly the resampled size that change removed.

So the split never recorded a real platform difference. What it did was let one side go stale without anything noticing, which is the opposite of what a golden image is for.

What the suffix cost

getEnvironment ran lsb_release -cs, or a sh -c subshell reading /etc/os-release if that was missing, to build the key. That is gone along with the os/exec, runtime, and sync imports it needed.

It also made new tests awkward. Several were added on amd64 with no arm64 counterpart, since this machine has no arm64 emulation, and every one of those PRs carried a note asking for -update to be run elsewhere. Five tests are in that state right now: TestAutolevel, TestBrightness, TestResizeIgnoreAspectRatio, TestResizeIgnoreAspectRatioWidthOnly, and TestThumbnailIgnoreAspectRatio. Collapsing to one set resolves all of them.

Which set was kept

The amd64 set, because it is complete at 21 files against 16, and because it is the one that reflects current behaviour for the rotate tests. The 16 arm64 files are removed.

If a platform difference ever does appear

CI runs these tests, so a regeneration that changes the bytes shows up as a failing check rather than as a silently divergent second set. That is a better signal than two sets where either may be stale.

.gitignore in resources/golden now covers *.failed.*, the diagnostic output written when a comparison fails.

Verification

In ghcr.io/beetlebugorg/go-dims:builder: gofmt, go vet, and go test -race ./... all pass. Removing a golden file still fails loudly:

no golden file at ../../resources/golden/grid.TestCrop.golden.png

- Drop the platform suffix from golden file names.
- Remove the environment lookup and its subprocess.
- Ignore failure output written next to the golden images.
@beetlebugorg
beetlebugorg merged commit c648477 into main Aug 27, 2026
3 checks passed
@beetlebugorg
beetlebugorg deleted the test/single-golden-set branch August 27, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant