【发布时间】:2018-06-27 06:46:10
【问题描述】:
由于我设法缩小了问题范围,因此我进行了重大修改:
我遇到了一个关于 devtools::test 的新问题。我的包过去通过单元测试没有任何问题。但是在更新我的包(包括 devtools 和 testthat)之后,它现在失败了。
可重现的例子:
我已经设法构建了一个可重现的示例:在一个新的包架构中。
foo.R:/R/中的R文件
foo <- function(obj){
return(as.numeric(obj))
}
test_foo.R:/tests/testthat 中的一个单元测试文件
test_that("Test my foo function: ",
{
expect_true(is.na(foo("1,5")))
})
testhat.R:在 /tests/ 中运行我的单元测试
library(testthat)
library(foo)
test_check("foo")
两种场景
运行:devtools::test()
> devtools::test()
Loading foo
Loading required package: testthat
Testing foo
√ | OK F W S | Context
Error in x[[method]](...) : attempt to apply non-function
== Results =====================================================================
Duration: 0.1 s
OK: 0
Failed: 4
Warnings: 1
Skipped: 0
运行 testtjat::test_dir("tests/")
> testthat::test_dir("tests/")
√ | OK F W S | Context
== testthat results ===========================================================
OK: 2 SKIPPED: 0 FAILED: 0
== Results =====================================================================
Duration: 0.1 s
OK: 0
Failed: 0
Warnings: 0
Skipped: 0
环境
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] foo_0.0.0.9000 testthat_2.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 roxygen2_6.0.1 rprojroot_1.3-2 crayon_1.3.4 assertthat_0.2.0 digest_0.6.14 withr_2.1.1 commonmark_1.4
[9] R6_2.2.2 backports_1.1.2 magrittr_1.5 cli_1.0.0 rlang_0.1.6 stringi_1.1.6 rstudioapi_0.7 xml2_1.1.1
[17] desc_1.1.1 devtools_1.13.4 tools_3.4.3 stringr_1.2.0 yaml_2.1.16 compiler_3.4.3 memoise_1.1.0
注意:
Github 上有一个关于这个问题的问题:https://github.com/hadley/devtools/issues/1675
【问题讨论】:
-
这个问题400% 太长了。请在标题和第一句话中清晰简洁地描述问题所在。
-
感谢您的反馈,但我不太确定如何改进这个需要描述我如何构建 muy 包的问题。你能提供一些建议吗?
-
好吧,'我遇到了一个关于 devtools::test 的新问题"' 几乎什么都没告诉我们。你的意思是 "devtools::test 在我的包(带有 X 警告),因为更改 Y”?或者它总是失败?或者它曾经在
assertthat 0.2.0/ devtools 1.13.4或其他包升级之前通过?(如果是这样,回滚并告诉我们包版本是什么known-good。)你真的需要定义“我遇到问题”的含义。在第一句话中。还有标题。如果这些不清楚,你会在第一行失去 90% 的观众。 -
将代码移至对问题的清晰简明描述下方。使用代码格式化对其进行格式化。为了便于阅读,使用水平分隔线将代码与其他部分分隔开来。