Skip to content

Improved vdiffr setup #2856

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 9 commits into from
Sep 1, 2018
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
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just occurred to me that we could set USE_VDIFFR to false here, and then I think the specific matrix env var would override this one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try that.

# 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