Skip to content

Commit 9eae13b

Browse files
Use CRAN vdiffr (#3054)
* rely on VDIFFR_RUN_TESTS envvar, which vdiffr checks directly, instead of USE_VDIFFR envvar
1 parent 9f1904d commit 9eae13b

File tree

5 files changed

+17
-47
lines changed

5 files changed

+17
-47
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ matrix:
88
include:
99
- r: devel
1010
- r: release
11-
env: USE_VDIFFR=true
11+
env: VDIFFR_RUN_TESTS=true
1212
before_cache:
1313
- Rscript -e 'remotes::install_cran("pkgdown")'
1414
- Rscript -e 'remotes::install_github("tidyverse/tidytemplate")'
@@ -28,7 +28,7 @@ env:
2828
# don't treat missing suggested packages as error
2929
- _R_CHECK_FORCE_SUGGESTS_=false
3030
# switch off vdiffr by default
31-
- USE_VDIFFR=false
31+
- VDIFFR_RUN_TESTS=false
3232

3333
after_success:
3434
- Rscript -e 'covr::codecov()'

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Suggests:
5555
sf (>= 0.3-4),
5656
svglite (>= 1.2.0.9001),
5757
testthat (>= 0.11.0),
58-
vdiffr
58+
vdiffr (>= 0.3.0)
5959
Enhances: sp
6060
License: GPL-2 | file LICENSE
6161
URL: http://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2

tests/figs/deps.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
ggplot2: 3.1.0.9000
2-
vdiffr-svg-engine: 0.9000
1+
- vdiffr-svg-engine: 1.0
2+
- vdiffr: 0.3.0
3+
- freetypeharfbuzz: 0.2.5

tests/testthat/helper-vdiffr.R

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
1-
# default is equal to whether NOT_CRAN is true or not
2-
enable_vdiffr <- identical(Sys.getenv("NOT_CRAN"), "true")
1+
# vdiffr ignores failures when
2+
# - VDIFFR_RUN_TESTS is "false" (on Travis CI with older versions and dev version of R)
3+
# - CI is not set (on CRAN)
34

4-
# disable or enable vdiffr based on the state of USE_VDIFFR, if set
5-
if (identical(Sys.getenv("USE_VDIFFR"), "true")) {
6-
enable_vdiffr <- TRUE
7-
} else if (identical(Sys.getenv("USE_VDIFFR"), "false")) {
8-
enable_vdiffr <- FALSE
9-
}
10-
11-
# disable vdiffr if version is old
12-
if (!requireNamespace("vdiffr", quietly = TRUE) ||
13-
utils::packageVersion("vdiffr") < "0.2.3.9001") {
14-
enable_vdiffr <- FALSE
15-
}
16-
17-
expect_doppelganger <- function(title, fig,
18-
path = NULL,
19-
...,
20-
user_fonts = NULL,
21-
verbose = FALSE) {
22-
if (!enable_vdiffr) {
23-
expect_error(regexp = NA, ggplot_build(fig))
24-
return(invisible(NULL))
25-
}
26-
27-
vdiffr::expect_doppelganger(title, fig,
28-
path = path,
29-
...,
30-
user_fonts = user_fonts,
31-
verbose = verbose
32-
)
33-
}
5+
expect_doppelganger <- vdiffr::expect_doppelganger

tests/testthat/test-geom-path.R

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@ test_that("geom_path draws correctly", {
3838
test_that("NA linetype is dropped with warning", {
3939
df <- data_frame(x = 1:2, y = 1:2, z = "a")
4040

41-
# Somehow the warning does not slip through on ggplot_build()
42-
if (enable_vdiffr) {
43-
expect_warning(
44-
expect_doppelganger(
45-
"NA linetype",
46-
ggplot(df, aes(x, y)) + geom_path(linetype = NA)
47-
),
48-
"containing missing values"
49-
)
50-
}
41+
expect_warning(
42+
expect_doppelganger(
43+
"NA linetype",
44+
ggplot(df, aes(x, y)) + geom_path(linetype = NA)
45+
),
46+
"containing missing values"
47+
)
5148
})

0 commit comments

Comments
 (0)