From rowe at muxspace.com  Wed Jan 22 17:55:00 2014
From: rowe at muxspace.com (Brian Lee Yung Rowe)
Date: Wed, 22 Jan 2014 11:55:00 -0500
Subject: [Rd] Behavior of --install-tests and testInstalledPackage
Message-ID: <1272735A-C8CB-44AF-8839-A39874790C34@muxspace.com>

Hello,

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,
Brian


[Rd] Behavior of --install-tests and testInstalledPackage
Brian Lee Yung Rowe