Skip to content

Commit 26414f3

Browse files
committed
Skip tests on old R versions
1 parent 0d8370d commit 26414f3

File tree

12 files changed

+17
-19
lines changed

12 files changed

+17
-19
lines changed

R/testthat-ui.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ expect_doppelganger <- function(title,
136136
testcase <- make_testcase_file(fig_name)
137137
writer(fig, testcase, title)
138138

139-
if (getRversion() < "4.1.0") {
139+
if (is_engine_stale()) {
140140
testthat::skip(paste_line(
141141
"The R graphics engine is too old.",
142142
"Please update to R 4.1.0 and regenerate the vdiffr snapshots."
@@ -173,6 +173,10 @@ is_collecting <- function() {
173173
!inherits(testthat::get_reporter(), "StopReporter")
174174
}
175175

176+
is_engine_stale <- function() {
177+
nzchar(Sys.getenv("_VDIFFR_CHECK_STALE")) && getRversion() < "4.1.0"
178+
}
179+
176180
str_standardise <- function(s, sep = "-") {
177181
stopifnot(is_scalar_character(s))
178182
s <- gsub("[^a-z0-9]", sep, tolower(s))

tests/testthat/helper-mock.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
vdiffr_skip_stale <- function() {
2+
skip_if_not_installed("base", "4.1.0")
3+
}
14

25
create_mock_pkg <- function(pkg = "mock-pkg") {
36
dir <- tempfile()

tests/testthat/test-cases.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
context("Cases")
1+
vdiffr_skip_stale()
32

43
test_that("Attributes are preserved", {
54
cases <- vdiffr:::cases(list(), "pkg_path", "deps")

tests/testthat/test-compare.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
context("File comparison")
1+
vdiffr_skip_stale()
32

43
write_tempfile <- function(lines) {
54
path <- tempfile()

tests/testthat/test-error.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
context("Thrown error")
1+
vdiffr_skip_stale()
32

43
collect_silently <- function(pkg) {
54
capture.output(suppressMessages(collect_cases(pkg)))

tests/testthat/test-expectations.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
context("Expectations")
1+
vdiffr_skip_stale()
32

43
test_that("Mismatches are skipped except on CI and interactively", {
54
notcran_result <- subset_results(test_results, "test-failed.R", "mismatches are hard failures when NOT_CRAN is set")[[1]]

tests/testthat/test-filter.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
context("Filtering")
1+
vdiffr_skip_stale()
22

33
test_that("Can filter to test certain cases", {
44
mock_pkg_dir <- create_mock_pkg("mock-pkg")

tests/testthat/test-ggplot.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
context("ggplot")
1+
vdiffr_skip_stale()
32

43
test_that("ggtitle is set correctly", {
54
ggplot_results <- subset_results(test_results, "test-ggplot.R", "ggtitle is set correctly")

tests/testthat/test-mismatch.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
context("mismatch")
1+
vdiffr_skip_stale()
22

33
test_that("failures are pushed to log file", {
44
log_path <- file.path(mock_pkg_dir, "tests", "vdiffr.Rout.fail")

tests/testthat/test-new.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
context("New cases")
1+
vdiffr_skip_stale()
32

43
test_that("New cases are skipped", {
54
new_results <- subset_results(test_results, "test-new.R", "New plots are collected")

0 commit comments

Comments
 (0)