Skip to content

Use CRAN vdiffr #3054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ matrix:
include:
- r: devel
- r: release
env: USE_VDIFFR=true
env: VDIFFR_RUN_TESTS=true
before_cache:
- Rscript -e 'remotes::install_cran("pkgdown")'
- Rscript -e 'remotes::install_github("tidyverse/tidytemplate")'
Expand All @@ -28,7 +28,7 @@ env:
# don't treat missing suggested packages as error
- _R_CHECK_FORCE_SUGGESTS_=false
# switch off vdiffr by default
- USE_VDIFFR=false
- VDIFFR_RUN_TESTS=false

after_success:
- Rscript -e 'covr::codecov()'
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Suggests:
sf (>= 0.3-4),
svglite (>= 1.2.0.9001),
testthat (>= 0.11.0),
vdiffr
vdiffr (>= 0.3.0)
Enhances: sp
License: GPL-2 | file LICENSE
URL: http://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2
Expand Down
5 changes: 3 additions & 2 deletions tests/figs/deps.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ggplot2: 3.1.0.9000
vdiffr-svg-engine: 0.9000
- vdiffr-svg-engine: 1.0
- vdiffr: 0.3.0
- freetypeharfbuzz: 0.2.5
36 changes: 4 additions & 32 deletions tests/testthat/helper-vdiffr.R
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
# default is equal to whether NOT_CRAN is true or not
enable_vdiffr <- identical(Sys.getenv("NOT_CRAN"), "true")
# vdiffr ignores failures when
# - VDIFFR_RUN_TESTS is "false" (on Travis CI with older versions and dev version of R)
# - CI is not set (on CRAN)

# disable or enable vdiffr based on the state of USE_VDIFFR, if set
if (identical(Sys.getenv("USE_VDIFFR"), "true")) {
enable_vdiffr <- TRUE
} else if (identical(Sys.getenv("USE_VDIFFR"), "false")) {
enable_vdiffr <- FALSE
}

# disable vdiffr if version is old
if (!requireNamespace("vdiffr", quietly = TRUE) ||
utils::packageVersion("vdiffr") < "0.2.3.9001") {
enable_vdiffr <- FALSE
}

expect_doppelganger <- function(title, fig,
path = NULL,
...,
user_fonts = NULL,
verbose = FALSE) {
if (!enable_vdiffr) {
expect_error(regexp = NA, ggplot_build(fig))
return(invisible(NULL))
}

vdiffr::expect_doppelganger(title, fig,
path = path,
...,
user_fonts = user_fonts,
verbose = verbose
)
}
expect_doppelganger <- vdiffr::expect_doppelganger
17 changes: 7 additions & 10 deletions tests/testthat/test-geom-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ test_that("geom_path draws correctly", {
test_that("NA linetype is dropped with warning", {
df <- data_frame(x = 1:2, y = 1:2, z = "a")

# Somehow the warning does not slip through on ggplot_build()
if (enable_vdiffr) {
expect_warning(
expect_doppelganger(
"NA linetype",
ggplot(df, aes(x, y)) + geom_path(linetype = NA)
),
"containing missing values"
)
}
expect_warning(
expect_doppelganger(
"NA linetype",
ggplot(df, aes(x, y)) + geom_path(linetype = NA)
),
"containing missing values"
)
})