Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 27 additions & 6 deletions tests/testthat/test-Plot-snapshots.R
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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(
{
Expand Down Expand Up @@ -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)
Expand All @@ -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
})
}

Expand All @@ -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()
Expand Down Expand Up @@ -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")
Expand All @@ -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) {
Expand Down
Loading