mardi 7 avril 2015

What directory tree does `R CMD check` see when it runs the tests?

I'm wondering what files and folders are visible when R CMD is running the tests under the tests/testthat folder?


I've noticed that the test command can see the tests directory, but that the R directory and the DESCRIPTION and NAMESPACE files are not visible.


Here is a sample unittest file that I placed under tests/testthat/test-whereami.R:



test_that("where am i", {
expect_true(file.exists("../../R"))
expect_true(file.exists("../../tests"))
expect_true(file.exists("../../DESCRIPTION"))
expect_true(file.exists("../testthat.R"))
})


When I run the tests using the devtools::test(), all tests pass (as they should). But when I check the package, the first and third tests fail; only files/folders inside tests/ seem to be visible.


I want to know what exactly is visible to the testing tool? I couldn't figure out a way to see exactly what files and folders are visible, I've tried:



  • placing a browser() inside the test file

  • placing a print(list.files()) inside the test suite

  • place a write.table(list.files("../.."), file = "aaaa.txt")


Using these approaches, running devtools::test() did show me what it sees, but that wasn't very useful because devtools::test() passes all the tests anyway. When running check, the things I tried did not produce anything (no print statements/no files were written).


Thanks


Aucun commentaire:

Enregistrer un commentaire