Skip to content

Commit

Permalink
Improved vdiffr setup (tidyverse#2856)
Browse files Browse the repository at this point in the history
* create vdiffr validation failure in segment annotations test

* run vdiffr on travis only on current R release

* use environment variable USE_VDIFFR

* fix broken reference image

* try simpler setup for Travis

* finalize vdiffr setup
  • Loading branch information
clauswilke authored Sep 1, 2018
1 parent 07b7457 commit 6e545dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
24 changes: 13 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ cache: packages
sudo: true
dist: trusty

addons:
apt:
packages:
- libfreetype6

r:
- 3.1
- 3.2
- oldrel
- release
- devel
# build matrix; turn on vdiffr only on r release
matrix:
include:
- r: devel
- r: release
env: USE_VDIFFR=true
- r: oldrel
- r: 3.2
- r: 3.1

# work around temporary travis + R 3.5 bug
r_packages: devtools

# Install manually because dev vdiffr is not compatible with Appveyor yet
r_github_packages: lionel-/vdiffr

# environment variables set for all builds
env:
global:
# don't treat missing suggested packages as error
- _R_CHECK_FORCE_SUGGESTS_=false
# switch off vdiffr by default
- USE_VDIFFR=false

after_success:
- Rscript -e 'covr::codecov()'
Expand Down
14 changes: 9 additions & 5 deletions tests/testthat/helper-vdiffr.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# default is equal to whether NOT_CRAN is true or not
enable_vdiffr <- identical(Sys.getenv("NOT_CRAN"), "true")

enable_vdiffr <- TRUE

if (!requireNamespace("vdiffr", quietly = TRUE) ||
utils::packageVersion("vdiffr") < "0.2.3.9000") {
# 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
}

if (paste(R.Version()$major, R.Version()$minor, sep = ".") < "3.3.0") {
# disable vdiffr if version is too old
if (!requireNamespace("vdiffr", quietly = TRUE) ||
utils::packageVersion("vdiffr") < "0.2.3.9000") {
enable_vdiffr <- FALSE
}

Expand Down

0 comments on commit 6e545dc

Please sign in to comment.