diff --git a/.travis.yml b/.travis.yml index 62f1fc30b2..040a5198f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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")' @@ -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()' diff --git a/DESCRIPTION b/DESCRIPTION index 8cfca78191..036f1f5b28 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/tests/figs/deps.txt b/tests/figs/deps.txt index 039800478b..059d357267 100644 --- a/tests/figs/deps.txt +++ b/tests/figs/deps.txt @@ -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 diff --git a/tests/testthat/helper-vdiffr.R b/tests/testthat/helper-vdiffr.R index 9d42c9335e..77f38e3155 100644 --- a/tests/testthat/helper-vdiffr.R +++ b/tests/testthat/helper-vdiffr.R @@ -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 diff --git a/tests/testthat/test-geom-path.R b/tests/testthat/test-geom-path.R index a99dd114f2..1f8007a8e1 100644 --- a/tests/testthat/test-geom-path.R +++ b/tests/testthat/test-geom-path.R @@ -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" + ) })