test: give the rePlot snapshot its own name (fixes a hard ERROR on all Linux/Windows legs) - #45
Merged
eliotmcintire merged 2 commits intoSep 4, 2026
Conversation
`test_that("rePlot doesn't work")` took two snapshots under one name: it
called `announce_snapshot_file()` + `expect_snapshot_file()` twice with the
same `fil`, `unlink()`ing the file in between. testthat rejects a duplicate
snapshot name outright, so the second call errored and aborted the test:
Error ('test-Plot-snapshots.R:612:5'): rePlot doesn't work
Snapshot file names must be unique. "rePlot_doesn't_work1Linux.png" has
already been used.
This is a plain ERROR on every Linux and Windows leg (macOS is unaffected --
`oses` is c("Win", "Linux"), so no snapshot runs there), and it predates the
CI migration: the same failure is in the development-branch run from
2026-08-29, run 33278110145.
The second snapshot now gets a name derived from the first rather than a
second `fn()` call, because `fn()` bumps the shared `counter` and that would
renumber every snapshot after this one. `unlink(fil)` goes with it -- it only
existed to clear the path for reuse.
Two new reference images follow in the next commit, recorded from CI.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011kpoQV6nNqcknk16R3RzBB
All three are taken from this branch's own CI run 33897686977, not rendered locally -- expect_snapshot_file() compares PNG bytes exactly and those bytes depend on the runner's cairo and fontconfig. rePlot_doesn't_work0Win-rePlot.png (windows-latest, release) rePlot_doesn't_work1Linux-rePlot.png (ubuntu-latest, release) Plot_listsggplotVnewer2Linux.png (ubuntu-latest, release) The two rePlot images are byte-identical to their non-rePlot counterparts already in the repo -- which is exactly the assertion the original code was reaching for with "same file for snapshot b/c basename is same as previous": rePlot() reproduces the plot pixel for pixel. It just could not express that through a snapshot name testthat had already seen. Plot_listsggplotVnewer2Linux.png closes a pre-existing gap unrelated to this branch: only the ...2Win.png variant had ever been committed, so test-Plot-snapshots.R:703 reported "Adding new file snapshot" on every Linux leg, including in the development run from 2026-08-29. As a side check, the Linux and Windows artifacts from that run reproduce the already-committed rePlot_doesn't_work1Linux.png and rePlot_doesn't_work0Win.png byte for byte, so those legs are stable and the new files are recorded against the same rendering. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011kpoQV6nNqcknk16R3RzBB
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two commits:
b9a1ce6— give the rePlot snapshot its own name.test_that("rePlot doesn't work")took two snapshots under a single name:announce_snapshot_file()+expect_snapshot_file()twice with the samefil,unlink()ing the file in between. testthat rejects a duplicate snapshot name, so the second call errored and aborted the test:The second snapshot now gets its own name derived from the first —
sub("\\.png$", "-rePlot.png", fil)— rather than a secondfn()call, becausefn()bumps the sharedcounterand that would renumber every snapshot after this one.unlink(fil)goes with it; it only existed to clear the path for reuse.2724b9d— record three missing fixtures, taken from this branch's own run 33897686977, not rendered locally (expect_snapshot_file()compares PNG bytes exactly, and those bytes depend on the runner's cairo/fontconfig):rePlot_doesn't_work0Win-rePlot.pngrePlot_doesn't_work1Linux-rePlot.pngPlot_listsggplotVnewer2Linux.png…2Win.pngvariant had ever been committed, so:703reported "Adding new file snapshot" on every Linux legBoth rePlot images come out byte-identical to their non-rePlot counterparts already in the repo — which is precisely the assertion the original code was reaching for with "same file for snapshot b/c basename is same as previous":
rePlot()reproduces the plot pixel for pixel. It just could not express that through a name testthat had already seen.This was not caused by the CI migration
The identical failure set is in the
developmentrun from 2026-08-29, run 33278110145, before PR #44 existed. It went unnoticed because the oldR-CMD-check.yamltriggered on[master, development]and there is nomasterbranch, so R-CMD-check never ran againstmain. macOS was always green becauseoses <- c("Win", "Linux")(helper-testInit.R:83) — no snapshot test runs there at all.Result — run 33899141206
FAIL 2FAIL 5FAIL 4PASSwent 173 → 174 on Linux.What is left, and why it is not fixed here
The four remaining Windows failures are rendering drift against committed references —
Issue 20; arr working(:765) andIssue 32 Plot factors lower case id(:793×2,:812). Measured pixel-for-pixel, they come to 7 changed pixels out of 1,920,000, max channel delta 58/255, and in every case the changed pixels sit inside a text glyph — a plot titlemaps$forestAge, or the legend labelA. Font antialiasing on thewindows-latestrunner image, not a plotting change.Accepting them is a judgement call about reference images, so it is left to the maintainer rather than folded into this PR.
Worth considering separately
expect_snapshot_file()compares PNG bytes exactly, so a one-pixel change in a font rasteriser is indistinguishable from a real regression. A tolerance-based comparator (compare = function(old, new) …with a small per-pixel budget) would keep the signal and drop this class of failure. Out of scope here.Related
The
_R_CHECK_DEPENDS_ONLY_leg fails for a different, structural reason — handled in #46.🤖 Generated with Claude Code
https://claude.ai/code/session_011kpoQV6nNqcknk16R3RzBB