diff --git a/tests/testthat/_snaps/Plot-snapshots/Issue_20;_arr_working0Win.png b/tests/testthat/_snaps/Plot-snapshots/Issue_20;_arr_working0Win.png index a07e29b..258d175 100644 Binary files a/tests/testthat/_snaps/Plot-snapshots/Issue_20;_arr_working0Win.png and b/tests/testthat/_snaps/Plot-snapshots/Issue_20;_arr_working0Win.png differ diff --git a/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id0Win.png b/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id0Win.png index 76d9001..edbb468 100644 Binary files a/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id0Win.png and b/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id0Win.png differ diff --git a/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id2Win.png b/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id2Win.png index bd8b22c..71437ac 100644 Binary files a/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id2Win.png and b/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id2Win.png differ diff --git a/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id4Win.png b/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id4Win.png index 89abd82..11a3a66 100644 Binary files a/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id4Win.png and b/tests/testthat/_snaps/Plot-snapshots/Issue_32_Plot_factors_lower_case_id4Win.png differ 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 5058c19..fc18695 100644 --- a/tests/testthat/test-Plot-snapshots.R +++ b/tests/testthat/test-Plot-snapshots.R @@ -1,6 +1,17 @@ +## The image snapshots in this file were all recorded with the full Suggests set +## installed, and `raster` in particular changes what gets recorded: several +## tests double the length of their `rasts` list when `raster` is available, and +## snapshot file names come from a running `counter` over those lists (see `fn()` +## in helper-testInit.R). With `raster` absent -- as on the `_R_CHECK_DEPENDS_ONLY_` +## CI leg -- the same names line up against different plots, so every snapshot +## after the first `requireNamespace("raster")` block compares the wrong image. +## Rather than maintain a second set of reference images, skip the image tests +## when `raster` is missing; the rest of the suite still exercises the package. + ## block B test_that("image content is not error-free", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) on.exit( @@ -80,6 +91,7 @@ test_that("image content is not error-free", { # # ## block C test_that("plotting colors", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) on.exit( { @@ -130,6 +142,7 @@ test_that("plotting colors", { # ## test.png 10 to 11 test_that("internal functions in Plot", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) on.exit( { @@ -208,6 +221,7 @@ test_that("internal functions in Plot", { ## block E 15 to test_that("Plot 2 is not error-free", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) on.exit( { @@ -463,6 +477,7 @@ test_that("setColors is not error-free", { # block G test_that("Plot with base is not error-free", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) on.exit( { @@ -586,6 +601,7 @@ test_that("Plot messages and warnings and errors", { ## block I test_that("rePlot doesn't work", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) for (os in oses) { fil <- fn(tmpdir, desc, counter, os, envir = envirHere) @@ -605,17 +621,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 }) } @@ -642,6 +660,7 @@ test_that("Plot - going through package coverage", { # block K test_that("Plot lists", { prevLastPlotNumber <- 48 + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) clearPlot() @@ -753,6 +772,7 @@ test_that("Plot functions NOT in quickPlot, i.e. redefining Plot", { }) test_that("Issue 20; arr working", { + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) files <- dir(system.file("maps", package = "quickPlot"), full.names = TRUE, pattern = "tif") @@ -777,6 +797,7 @@ test_that("Issue 20; arr working", { test_that("Issue 32 Plot factors lower case id", { prevLastPlotNumber <- 51 + skip_if_not_installed("raster") testInit("terra", opts = list(quickPlot.verbose = TRUE), dev = FALSE) for (colPalette in 1:2) {