Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip a specific test file on travis in R

My testing suite is made of multiple files. I would like to skip one of them on travis (the one related to fitting Bayesian models) because it takes to much time and fails.

I know that I can skip specific tests with testthat::skip_on_travis(). However, these work in a test_that block. Unfortunately, the part I wish to skip (from here to here) is mainly outside the test_that block (and is the model fitting occurring before testing).

I tried putting the model fitting inside a test_that block, but then the other blocks do not find the models. I also tried nested test_that block, but that seems not to work... any ideas?

like image 582
Dominique Makowski Avatar asked Jan 20 '26 13:01

Dominique Makowski


2 Answers

Another option that seems to work is to check the environment variables:

if (Sys.getenv("USER") != "travis") {
  # tests to be executed...
}

See also here: https://docs.travis-ci.com/user/environment-variables/#default-environment-variables

like image 133
Daniel Avatar answered Jan 23 '26 15:01

Daniel


In your testthat.R file, you can use the filter argument to test_check in order to skip entire files conditionally. This mechanism can be used to skip collections of long tests on CRAN or Travis.

like image 35
Ben Goodrich Avatar answered Jan 23 '26 15:01

Ben Goodrich