I am following the hints to this question, but I'm impatient and I would like to run my tests more quickly, without having to wait for the 30+ checks that R CMD check src
invokes before checking tests
.
what I thought I could do was to add a --standalone
option to the doRUnit.R
suggested in that R-wiki page so that I could run the unit tests independently of R CMD
.
I added these lines to the script:
opt <- list(standalone=NULL)
if(require("getopt", quietly=TRUE)) {
## path to unit tests may be given on command line, in which case
## we also want to move the cwd to this script
opt <- getopt(matrix(c('standalone', 's', 0, "logical"),
ncol=4, byrow=TRUE))
if(!is.null(opt$standalone)) {
## switch the cwd to the dir of this script
args <- commandArgs()
script.name <- substring(args[substring(args, 1, 7)=="--file="], 8, 1000)
if(!is.null(script.name))
setwd(dirname(script.name))
}
}
with this change, the script finds the test.*\.R
files, independently from the directory from which I invoke the script.
the remaining problem now is that the doRUnit.R
script loads the installed library, it does not source()
the files that compose the library.
assuming that I want to load each and every file in the R
directory, how would I do that?
assuming you have a better testing schema (satisfying the requirements "quick", "uninstalled"), what is it?