【发布时间】:2014-11-09 02:00:44
【问题描述】:
我在 Rstudio (Windows 0.98.1056) 中运行 testthat,我收到以下错误。它似乎是在我更新 Rstudio 和安装的 R 包之后出现的,但我怀疑这两者可能没有直接关系。该错误也发生在一个非常简单的测试文件上。有人遇到过吗?
文件:tests/test-all.R
library(testthat)
library(matrixUtils)
test_package("matrixUtils")
文件:tests/testthat/matrixUtils-test.R
context("testa")
test_that("subsetting by one dimension", {
a <-1
expect_equal(a, 1)
})
错误信息:
==> Sourcing R files in 'tests' directory
Error: '\.' is an unrecognized escape in character string starting "'\." Execution halted
Exited with status 1.
sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit)
locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages: [1] grid stats graphics grDevices utils datasets methods base
other attached packages: [1] magrittr_1.1.0 matrixUtils_0.2 testthat_0.8.1 dplyr_0.2.0.99 reshape2_1.4 ggplot2_1.0.0 gridExtra_0.9.1 [8] zoo_1.7-11
loaded via a namespace (and not attached): [1] assertthat_0.1 colorspace_1.2-4 digest_0.6.4 gtable_0.1.2 lattice_0.20-29 MASS_7.3-34 munsell_0.4.2 [8] parallel_3.1.1 plyr_1.8.1 proto_0.3-10 Rcpp_0.11.2 scales_0.2.4 stringr_0.6.2 tools_3.1.1
>
【问题讨论】:
-
你应该证明一个reproducible example。不要只是粘贴错误消息,显示您正在运行的生成消息的代码。创建一个示例,我们可以运行该示例以得到与您相同的错误,否则我们真的无法确定是什么原因造成的。
-
除非我共享整个软件包,否则您的建议不太可行。但我很乐意分享测试代码。照原样提出问题仍然很有用:通常我可以在不知道代码的情况下说出构建/测试错误中的问题。
-
我建议您调试您的代码以生成一个最小的可重现示例。继续发布“非常简单的测试文件”,以便我们运行与您相同的东西。此错误消息似乎非常特定于字符串。如果没有具体的例子,我真的不明白你在这里期待什么样的答案。
-
这个问题是否只发生在
test_package()上?如果您只在示例文件中使用test_file()会怎样? (到目前为止,我一直无法重现。) -
我正要在 github 上发布这个包,但我验证了这个包在 Linux 上测试成功,但在 Windows 上没有。这似乎是一个重要的系统特定问题。