Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system quoting fails with testthat + CMD check #144

Closed
scottkosty opened this issue May 3, 2014 · 7 comments · Fixed by ropensci/weathercan#24
Closed

system quoting fails with testthat + CMD check #144

scottkosty opened this issue May 3, 2014 · 7 comments · Fixed by ropensci/weathercan#24

Comments

@scottkosty
Copy link

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.

@eddelbuettel
Copy link

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.

@scottkosty
Copy link
Author

Good to know, Dirk. Let's close this issue then.

@eddelbuettel
Copy link

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.

@scottkosty
Copy link
Author

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?

@hadley
Copy link
Member

hadley commented Jun 13, 2014

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" = "",

@fabian-s
Copy link

Just came here to confirm that adding

Sys.setenv("R_TESTS" = "")

to the testfile seems to take care of these issues.

@dtenenba
Copy link

dtenenba commented Apr 9, 2015

Has this been reported to R-core? If so, where? Thanks.

lgatto pushed a commit to lgatto/pRoloc that referenced this issue Apr 9, 2015
lgatto pushed a commit to lgatto/MSnbase that referenced this issue Apr 9, 2015
luckyrandom added a commit to luckyrandom/cmaker that referenced this issue Apr 24, 2015
luckyrandom added a commit to luckyrandom/cmaker that referenced this issue Apr 24, 2015
jranke added a commit to jranke/mkin that referenced this issue Jun 20, 2015
LTate pushed a commit to LTate/qFeature that referenced this issue Sep 28, 2015
davidgohel added a commit to davidgohel/rvg that referenced this issue Dec 15, 2015
flying-sheep added a commit to IRkernel/IRkernel that referenced this issue Sep 15, 2016
aappling-usgs added a commit to aappling-usgs/streamMetabolizer that referenced this issue Sep 20, 2016
lgatto pushed a commit to lgatto/MSnbase that referenced this issue Sep 7, 2017
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/MSnbase@102243 bc3139a8-67e5-0310-9ffc-ced21a209358
lgatto pushed a commit to lgatto/pRoloc that referenced this issue Sep 8, 2017
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/pRoloc@102237 bc3139a8-67e5-0310-9ffc-ced21a209358
jyypma added a commit to astamm/nloptr that referenced this issue Oct 6, 2017
Setting R_TESTS environment variable to emply string should solve error on Travis when running test that uses system.file.
klmr added a commit to klmr/box that referenced this issue Oct 6, 2017
The bug was due to R getting confused by set `R_TESTS` environment
variable; un-setting fixes the issue. See r-lib/testthat#144 for
details.
nhejazi added a commit to wilsoncai1992/adaptest that referenced this issue Nov 22, 2017
jranke added a commit to jranke/mkin that referenced this issue Jul 5, 2018
chasemc pushed a commit to chasemc/IDBacApp that referenced this issue Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants