Only run Integration Tests on PR, Unit tests always

In our company we have several packages that work together. We have written two types of tests, which we keep in 2 files:

  • a test file for the specific package ( specific.R ). These tests are very quick (I guess these are traditional unit tests?)
  • and one that we use to make sure all packages continue to work together and the overall result is fine ( overall.R ). These tests take a long time because we have to ensure that ALL steps of the process work for ALL the projects in the company (I guess these are traditional integration tests?)

Both tests are currently run when we push to github or create a PR through Travis, which implicitly runs this line of code( R CMD check *tar.gz ). As you well know, this runs all the tests in the testthat folder, and thus both files are run.

Now, we would like to choose which tests run when so that integration tests only run when we do a Pull-Request to the package (when we have introduced new functionality on a different dev branch) while the package-specific unit tests keep running every time we commit/push to the repo. We see in Create a new configurable cron job with travis that there is an event type TRAVIS_EVENT_TYPE through which we could distinguish different runs… would it be possible to perhaps rename the overall test file to .RignoreMe for normal runs and then if TRAVIS_EVENT_TYPE: "pull-request" rename *.RignoreMe *.R or some such?

Does this functionality make sense? It’s weird to me that I haven’t found more people trying to accomplish the same.

Thanks!


might have something for you.

Hi @BanzaiMan,

Thanks, that looks promising! Indeed I think that I can use some of those triggers. In fact, there’s a function testthis::test_integration() that runs all tests in the subfolder ./tests/testthat/integration_tests. I was under the expectation that a Travis build would run R CMD CHECK, which would run all the tests inside the testthat folder, but it would ignore all tests in subfolders within testthat. However, it seems that the normal Travis build is running tests in subfolders… as can be seen in the following runtimes:

(this is strange because if I run R CMD CHECK locally, the subfolder files are being ignored)
EDIT: IT APPEARS SUBFOLDERS ARE BEING IGNORED NOW Testing thoroughly will report back. Ignore me for now :slight_smile:

If we can get the Travis build to ignore files inside subfolders, then I can MANUALLY run the integration tests by doing the following in my travis.yml:

after_success:
if TRAVIS_EVENT_TYPE: "pull-request" R CMD testthis::test_integration()

(or whatever the syntax is)

Is there any way to force the Travis build to ignore subfolders?

R build’s behavior is explained in https://docs.travis-ci.com/user/languages/r.

If the default script steps do not behave the way you want, which you can see in


it is best to override it in script. Keep in mind that R does a lot of things under the hood.

1 Like
Imprint