[R-pkg-devel] how to skip tests on CRAN but NOT on travis-ci?
Dirk Eddelbuettel
edd at debian.org
Sun Jun 21 17:56:26 CEST 2015
On 21 June 2015 at 10:47, Dirk Eddelbuettel wrote:
| Environment variables are perfect for this. Eg in RcppRedis I can in fact
| assume Redis to be present on Travis (as Travis has a webby-ish focus where
| Redis is common) but am fairly certain win-builder and other machines do not.
|
| So in tests/runUnitTests.R I have (with two typos I fixed here)
|
|
|
| ## if we know a redis server is set up, we can signal this -- cf .travis.yml
| if (Sys.getenv("RunRcppRedisTests") == "yes") runTests <- TRUE
|
| ## here is a shortcut: if the user is 'edd' we also run tests
| ## ought to be wrong on CRAN, win-builder, ...
| if (Sys.getenv("USER") == "edd") runTests <- TRUE
|
And I forgot to show that in .travis.yml we do of course set this, and also
request a Redis server:
env:
global:
- _R_CHECK_FORCE_SUGGESTS_=FALSE
- RunRcppRedisTests=yes
services:
- redis-server
Dirk
| which shortly later is used in
|
|
| ## Tests for test run
| if (runTests) {
| ## Run tests
| tests <- runTestSuite(testSuite)
|
| ....
|
|
|
|
| This is generic, and you can surely adapt it from testthat.
|
|
|
| In Rcpp we do something pretty similar within the set of test files in order
| to remain within the one-minute limit.
|
| So in tests/doRUnit.R we do set an environment variable to turn tests on,
| else they are off by default:
|
|
| ## force tests to be executed if in dev release which we define as
| ## having a sub-release, eg 0.9.15.5 is one whereas 0.9.16 is not
| if (length(strsplit(packageDescription("Rcpp")$Version, "\\.")[[1]]) > 3) {
| if (Sys.getenv("RunAllRcppTests") != "no") {
| message("Setting \"RunAllRcppTests\"=\"yes\" for development release\n")
| Sys.setenv("RunAllRcppTests"="yes")
| }
| }
|
|
| Hope this helps, Dirk
|
|
| --
| http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
|
| ______________________________________________
| R-package-devel at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-package-devel
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the R-package-devel
mailing list