Below is a minimal example:
Put the following in tests/testthat.R:
options(warn = 2)
library(testthat)
test_check("anRpackage", report = "summary")
In tests/testthat/test.R
extcmd <- 'R -e \'print("hello")\''
system(extcmd, intern = TRUE)
Then run R CMD check
(either with 3.1 or with the current devel version), I get the following error:
* checking tests ...
Running ‘testthat.R’
ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
> library(testthat)
>
> test_check("anRpackage", report = "summary")
Loading required package: anRpackage
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
Calls: local ... eval.parent -> eval -> eval -> eval -> eval -> source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
cannot open file 'startup.Rs': No such file or directory
Execution halted
Error: (converted from warning) running command 'R -e 'print("hello")'' had status 1
Execution halted
If I source test.R
or run R CMD BATCH test.R
or put test.R
directly in the tests
folder and then run R CMD check
, it runs fine.
The error is similar to #129 and #86.
I'm using Ubuntu 64-bit, both 13.10 and 14.04.
It's R. I am getting the same issue if I just try some system("R CMD build ...")
via a file in tests/
-- no testthat involved (and I got here via Google...)
Ubuntu 14.04, R 3.1.0.
Good to know, Dirk. Let's close this issue then.
Noooo -- I want it fixed too :-/ We need to find a fix that is orthogonal to whether it gets tickled by devtools or testthat or youknowhat.
I agree but from your new information this sounds like an R issue, not a testthat issue right? I certainly don't mind keeping this bug open, but I would not want to clutter testthat with a bug that's not really actionable by its author, unless we consider a work around I suppose.
Don't you think it's better to report this to R core and deal with it there?
This is an R issue. In devtools we have (in the context of setting environment variables):
# When R CMD check runs tests, it sets R_TESTS. When the tests
# themeselves run R CMD xxxx, as is the case with the tests in
# devtools, having R_TESTS set causes errors because it confuses
# the R subprocesses. Unsetting it here avoids those problems.
"R_TESTS" = "",
Just came here to confirm that adding
Sys.setenv("R_TESTS" = "")
to the testfile seems to take care of these issues.
Has this been reported to R-core? If so, where? Thanks.
Most helpful comment
Has this been reported to R-core? If so, where? Thanks.