2

I am running testthat in Rstudio (Windows 0.98.1056), and I get the following error. It seems to have appeared after I updated Rstudio and the installed R packages, but I suspect the two may not be directly related. The error occurs also on a very simple test file. Has anyone encountered this?

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)
})

Error message:

==> 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     
>
gappy
  • 10,095
  • 14
  • 54
  • 73
  • 1
    You should proved a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Don't just paste the error message, show the code you were running that generated the message. Create an example that we can run to get the same error as you, otherwise we don't really have a way to know for sure what's causing this. – MrFlick Sep 15 '14 at 14:12
  • Unless I share the whole package, what you are proposing is not quite feasible. But I am happy to share the testing code. Asking the question as it is can still be useful: oftentimes I can tell what was the problem in build/test errors without knowing the code. – gappy Sep 15 '14 at 14:28
  • I'm suggesting you debug your code to produce a minimal reproducible example. Go ahead and post the "very simple test file" so we are running the same thing as you. This error message seems very specific to character strings. I really don't understand what sort of answer you are expecting here without a specific example. – MrFlick Sep 15 '14 at 14:34
  • Does this problem occur exclusively with `test_package()`? What if you just use `test_file()` on your sample file? (So far I've been unable to reproduce.) – MrFlick Sep 15 '14 at 17:34
  • I was about to post the package on github, but I verified that the package tests successfully on Linux but not on Windows. It seems a non-trivial system-specific issue. – gappy Sep 15 '14 at 20:25
  • @gappy I am having the same problem. Did you able to solve it? – HBat Oct 16 '14 at 12:19
  • @HBatI think I updated testthat on Linux, and the problem disappeared. – gappy Oct 17 '14 at 13:34

1 Answers1

1

It's hard to check your error without the package. Some ideas:

This was a similar error reported in #187 on github/hadley/testthat.

  1. Update testthat package. Latest is 0.9.1. Issue was closed but looks hard to reproduce. @hadley suggests a fix

    check that devtools is enabled under project options in RStudio

    renkun-ken added library(devtools) as a last resort in his Rprofile.

    I start RStudio without .Rprofile which runs library(devtools). Test from Test package does not work, then I run devtools::test() as you suggest, and it works.

  2. If this does not work. Check your paths and use file.path() to create paths using strings in your package. This error seems to crop up with paths misspecified.

Hope this helps gappy and you get the "woot" happy test messages soon!

M

Community
  • 1
  • 1
micstr
  • 5,080
  • 8
  • 48
  • 76