【发布时间】:2015-10-30 23:22:44
【问题描述】:
我们正在尝试将一些单元测试添加到由 travis 运行的 caret package,但不在 CRAN 上。这节省了 CRAN 的构建时间并减少了他们必须安装以检查我们的包的依赖项数量,同时让我们在 travis 上运行更完整的测试套件。
我想我可以使用travis.yml file 中的r_packages: 行简单地安装测试要求:
r_packages:
- ROSE
- DMwR
However, my NOT_CRAN=TRUE builds are still failing。 (NOT_CRAN=FALSE 运行良好,因为跳过了有问题的测试)
这真的很奇怪,作为when I look at the build logs,我看到travis成功安装了我需要的所有包:
* installing *source* package ‘ROSE’ ...
** package ‘ROSE’ successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (ROSE)
但是当我的测试依赖于这些包运行时,R 找不到它们:
> library(testthat)
> library(caret)
Loading required package: lattice
Loading required package: ggplot2
>
> test_check("caret")
[1] "Reduced dimension to 3 by default. "
1 package is needed for this model and is not installed. (ROSE). Would you like to try to install it now?1. Error: check appropriate sampling calls by name -----------------------------
1: withCallingHandlers(eval(code, new_test_environment), error = capture_calls, message = function(c) invokeRestart("muffleMessage"),
warning = function(c) invokeRestart("muffleWarning"))
2: eval(code, new_test_environment)
3: eval(expr, envir, enclos)
4: caret:::parse_sampling(i) at test_sampling_options.R:14
5: checkInstall(pkgs)
6: stop()
testthat results ================================================================
OK: 62 SKIPPED: 0 FAILED: 1
1. Error: check appropriate sampling calls by name
Error: testthat unit tests failed
Execution halted
(我认为)relevant line of code is here in caret's source code:
good <- rep(TRUE, length(pkg))
for(i in seq(along = pkg)){
tested <- try(find.package(pkg[i]), silent = TRUE)
if(class(tested)[1] == "try-error") good[i] <- FALSE
}
为什么find.package函数找不到travis安装的包?他们会进入某个特殊的、独立的图书馆吗?
另外,顺便说一句,我如何让我的 travis 构建为 r 不那么冗长?默认情况下,它们似乎打印了太多信息(例如,它回显了测试和手册运行的所有代码,甚至是没有错误的代码)。
【问题讨论】: