To run specific tests on Travis only for Pull Requests, I would suggest taking advantage of the default environment variables set by Travis.
For example, the function below will skip a test on a Travis build that isn't a pull request:
skip_on_travis_commit <- function() {
on_travis <- Sys.getenv("TRAVIS")
is_pr <- Sys.getenv("TRAVIS_PULL_REQUEST")
if (identical(on_travis, "true") && identical(is_pr, "false")) {
skip("Skip workflow test on Travis commit")
}
return(invisible(TRUE))
}
Then for any workflow test you want to skip, you can add the function call at the beginning:
test_that("A long running workflow test", {
skip_on_travis_commit()
...
})