Search code examples
rtravis-citestthatrstan

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?


Solution

  • 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