You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I test a package (in RStudio, but I don't think that matters here) by running test(), a side-effect is that all functions are exported to the main console namespace afterward. This catches me by surprise, and confuses matters when I'm trying to get my @exports straightened out.
I would prefer to never have all functions exported, even in my test scripts, because I want my code to see the same view of the package that a normal user would.
Short of that, is there a way to clean up the environment after running test()?
load_all(reset = TRUE, export_all = FALSE) should do it.
It does this because it's my expectation (and practice) that you want to test functions that the user can't see. The role of unit tests is not to catch export problems.
Yeah, that probably should be an option for documentation too (and do same thing for run examples). We need an easy way to tell devtools to run these command in a separate process.
I'm going to put this aside for now - I don't think there's any solution that works better than the current approximation without introducing other major problems. In the long run, we made be able to solve this within Rstudio, by taking advantage of existing Rstudio code for interacting with sub-processes.
Activity
hadley commentedon Feb 20, 2013
load_all(reset = TRUE, export_all = FALSE)should do it.It does this because it's my expectation (and practice) that you want to test functions that the user can't see. The role of unit tests is not to catch export problems.
kenahoo commentedon Feb 20, 2013
My main point is that the effect lasts even after the tests are completed. The functions are not just exported for the duration of testing.
wch commentedon Feb 20, 2013
I think the right thing to do is run the tests in a separate R session, to avoid this and other side-effects.
hadley commentedon Feb 20, 2013
Yeah, that probably should be an option for documentation too (and do same thing for run examples). We need an easy way to tell devtools to run these command in a separate process.
hadley commentedon Mar 28, 2013
@wch The downside of doing that is you can no longer interact with the tests (e.g.) with
browser()Run tests in clean environment.
hadley commentedon Mar 29, 2013
I'm going to put this aside for now - I don't think there's any solution that works better than the current approximation without introducing other major problems. In the long run, we made be able to solve this within Rstudio, by taking advantage of existing Rstudio code for interacting with sub-processes.