Skip to content

Avoid export_all during test() #258

Closed

Description

@kenahoo

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

Activity

  1. hadley commented on Feb 20, 2013

    @hadley
    Member

    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.

  2. kenahoo commented on Feb 20, 2013

    @kenahoo
    Author

    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.

  3. wch commented on Feb 20, 2013

    @wch
    Member

    I think the right thing to do is run the tests in a separate R session, to avoid this and other side-effects.

  4. hadley commented on Feb 20, 2013

    @hadley
    Member

    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.

  5. hadley commented on Mar 28, 2013

    @hadley
    Member

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

  6. added a commit that references this issue on Mar 28, 2013
    d781f1f
  7. hadley commented on Mar 29, 2013

    @hadley
    Member

    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.

  8. locked and limited conversation to collaborators on Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions