testthat中的神秘错误消息

时间:2014-09-15 13:58:00

标签: r testthat

我在Rstudio(Windows 0.98.1056)中运行testthat,我收到以下错误。在我更新了Rstudio和已安装的R软件包后似乎已经出现,但我怀疑这两个可能没有直接关系。在一个非常简单的测试文件上也会发生错误。有没有人遇到过这个?

file:tests / test-all.R

library(testthat)
library(matrixUtils)
test_package("matrixUtils")

file: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     
>

1 个答案:

答案 0 :(得分:1)

没有包裹很难检查你的错误。一些想法:

这是github / hadley / testthat上的similar error reported in #187

  1. 更新testthat包。最新版本为0.9.1。 问题已经结束但看起来难以重现。 @hadley建议修复

      

    检查在RStudio

    中的项目选项下是否启用了devtools
    renkun-ken在他的Rprofile中添加了库(devtools)作为最后的手段。

      

    我没有运行库(devtools)的.Rprofile启动RStudio。从测试包中测试不起作用,然后按照你的建议运行devtools :: test(),它可以工作。

  2. 如果这不起作用。 检查您的路径并使用file.path() 在您的包中使用字符串创建路径。 This error似乎突然出现错误的路径。

  3. 希望这有助于gappy,并且很快就能获得“woot”快乐测试消息!

    中号

相关问题