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

Avoid export_all during test() #258

Closed
kenahoo opened this Issue Feb 20, 2013 · 6 comments

Comments

Projects
None yet
3 participants
@kenahoo

kenahoo commented Feb 20, 2013

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()?

@hadley

This comment has been minimized.

Member

hadley commented 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

This comment has been minimized.

kenahoo commented 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

This comment has been minimized.

Member

wch commented 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

This comment has been minimized.

Member

hadley commented 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

This comment has been minimized.

Member

hadley commented Mar 28, 2013

@wch The downside of doing that is you can no longer interact with the tests (e.g.) with browser()

hadley added a commit that referenced this issue Mar 28, 2013

@hadley

This comment has been minimized.

Member

hadley commented 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.

@hadley hadley closed this in 05ab6fb Apr 1, 2013

@lock lock bot locked and limited conversation to collaborators Sep 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.