我正在关注this question的提示,但我很不耐烦,希望能够更快地运行我的测试,而不必等待之前R CMD check src
所调用的30+个检查。RUnit测试已卸载的软件包
什么,我想我唯一能做的就是增加一个--standalone
选项将doRUnit.R
在that R-wiki page建议,这样我可以独立运行的R CMD
单元测试。
我添加了这些行脚本:
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))
}
}
这种变化,剧本找到test.*\.R
文件,分别从我调用脚本的目录。
现在剩下的问题是,doRUnit.R
脚本加载了安装的库,它不包含source()
组成库的文件。
假设我想加载R
目录中的每个文件,我该怎么做?
假设您有一个更好的测试模式(满足“快速”,“卸载”的要求),它是什么?
到底调用,我混我自己的答案与你的:我第一次安装包,然后我运行doRUnit - -standalone。它更快,我看到控制台上的输出。 – mariotomo 2009-12-18 14:16:24
以后更新:我有一个[Makefile](https://r-forge.r-project.org/scm/viewvc.php/\*checkout\*/pkg/inst/RUnit/Makefile?root = delftfews)在unittests目录中定义一个目标(xtest),它产生在emacs的'* compilation *'缓冲区中有用的输出。 – mariotomo 2010-08-09 09:11:17