Skip to content

Commit a1a30e7

Browse files
committed
Allow overriding skipping of tests with VDIFFR_RUN_TESTS
1 parent 47566c7 commit a1a30e7

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ check how the appearance of your figures changes over time, and to
5252
manually assess whether changes reflect actual problems in your
5353
package.
5454

55+
If you need to override the default vdiffr behaviour on CRAN (not
56+
recommended) or Travis (for example to run the tests in a particular
57+
builds but not others), set the `VDIFFR_RUN_TESTS` environment
58+
variable to "true" or "false".
59+
5560

5661
## Features
5762

R/testthat-ui.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@
6767
#' manually assess whether changes reflect actual problems in your
6868
#' package.
6969
#'
70+
#' If you need to override the default vdiffr behaviour on CRAN (not
71+
#' recommended) or Travis (for example to run the tests in a
72+
#' particular builds but not others), set the `VDIFFR_RUN_TESTS`
73+
#' environment variable to "true" or "false".
74+
#'
7075
#' @section Debugging:
7176
#'
7277
#' It is sometimes difficult to understand the cause of a failure.

R/utils.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,18 @@ hash_encode_url <- function(url){
172172
}
173173

174174
is_ci <- function() {
175+
override <- Sys.getenv("VDIFFR_RUN_TESTS")
176+
if (nzchar(override)) {
177+
override <- parse_expr(toupper(override))
178+
if (!is_bool(override)) {
179+
abort("`VDIFFR_RUN_TESTS` must be \"true\" or \"false\"")
180+
}
181+
return(override)
182+
}
183+
175184
nzchar(Sys.getenv("CI")) || nzchar(Sys.getenv("NOT_CRAN"))
176185
}
186+
187+
is_bool <- function(x) {
188+
is_logical(x, n = 1) && !is.na(x)
189+
}

man/expect_doppelganger.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-utils.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
context("utils")
2+
3+
test_that("can override is_ci()", {
4+
with_override <- function(var) {
5+
withr::with_envvar(c(VDIFFR_RUN_TESTS = var, CI = "", NOT_CRAN = ""), is_ci())
6+
}
7+
expect_true(with_override("true"))
8+
expect_false(with_override("false"))
9+
expect_error(with_override("falsish"), "must be")
10+
})

0 commit comments

Comments
 (0)