[Rd] Behavior of --install-tests and testInstalledPackage

Brian Lee Yung Rowe rowe at muxspace.com
Wed Jan 22 17:55:00 CET 2014


I'm writing a script that automates the testing of reverse dependencies of a package. I found the function testInstalledPackage in the tools package, which seems to do what I want. However, when I use it for a source package that was installed with --install-tests, I've noticed that only the actual test files (e.g. located in inst/tests) are available and run. In other words the test harness script (e.g. in tests) is not copied, so any wiring to run tests isn't available when running testInstalledPackage. 

I tried loading the required packages (i.e. the installed package to retest plus the testing frameworks RUnit, testthat), but since testInstalledPackage makes an external call to R CMD BATCH, any packages loaded in my current environment have no effect on the tests. The only workaround that I've come up with is to add require statements to the top of each test file, but this is a bit onerous.

My question is whether
1) there is a technique to force the test harness script (e.g. tests/run_tests.R, tests/doRUnit.R) to be copied into the installed source package, or
2) there is a way to have testInstalledPackage force the loading of required packages prior to executing test scripts, or
3) has someone already done this?

Thanks and Regards,

More information about the R-devel mailing list