diff --git a/tests/testthat/_snaps/Plot-snapshots/Plot_listsggplotVnewer2Linux.png b/tests/testthat/_snaps/Plot-snapshots/Plot_listsggplotVnewer2Linux.png new file mode 100644 index 0000000..6a846ba Binary files /dev/null and b/tests/testthat/_snaps/Plot-snapshots/Plot_listsggplotVnewer2Linux.png differ diff --git a/tests/testthat/_snaps/Plot-snapshots/rePlot_doesn't_work0Win-rePlot.png b/tests/testthat/_snaps/Plot-snapshots/rePlot_doesn't_work0Win-rePlot.png new file mode 100644 index 0000000..fdda827 Binary files /dev/null and b/tests/testthat/_snaps/Plot-snapshots/rePlot_doesn't_work0Win-rePlot.png differ diff --git a/tests/testthat/_snaps/Plot-snapshots/rePlot_doesn't_work1Linux-rePlot.png b/tests/testthat/_snaps/Plot-snapshots/rePlot_doesn't_work1Linux-rePlot.png new file mode 100644 index 0000000..06d4dd4 Binary files /dev/null and b/tests/testthat/_snaps/Plot-snapshots/rePlot_doesn't_work1Linux-rePlot.png differ diff --git a/tests/testthat/test-Plot-snapshots.R b/tests/testthat/test-Plot-snapshots.R index 381647a..0c93091 100644 --- a/tests/testthat/test-Plot-snapshots.R +++ b/tests/testthat/test-Plot-snapshots.R @@ -603,17 +603,19 @@ test_that("rePlot doesn't work", { fil }) - unlink(fil) - - # same file for snapshot b/c basename is same as previous - announce_snapshot_file(name = basename(fil)) + ## testthat rejects reusing a snapshot name within a run, so the rePlot + ## output needs its own. Derive it from `fil` rather than calling `fn()` + ## again: `fn()` bumps the shared `counter`, which would rename every + ## snapshot after this one. + filRePlot <- sub("\\.png$", "-rePlot.png", fil) + announce_snapshot_file(name = basename(filRePlot)) if (correctOS(os)) expect_snapshot_file({ - png(filename = fil, width = 400, height = 300) + png(filename = filRePlot, width = 400, height = 300) b <- dev.cur() rePlot(a, b) dev.off(b) - fil + filRePlot }) }