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

test() won't work after check() when S4 methods are involved #60

Closed
garrettgman opened this issue Feb 8, 2012 · 5 comments
Closed

test() won't work after check() when S4 methods are involved #60

garrettgman opened this issue Feb 8, 2012 · 5 comments

Comments

@garrettgman
Copy link

...and vice versa

For example, after running

check("lubridate")

test produces the following error

test("lubridate")
Loading lubridate
Error: package slot missing from signature for generic ‘[<-’
  and classes Interval, ANY
  cannot use with duplicate class names (the package may need to be re-installed)

It seems test is trying to reload the S4 methods of lubridate, but gets confused because the methods are already loaded from check(). As a result, test isn't sure how to differentiate the methods it wants to load. The same thing happens when I run check() after test().

The error comes from R's behavior: The same thing happens outside of devtools if I try redefining existing S4 methods. I can use removeMethod("[<-,Interval,ANY") to postpone the error message until R encounters the next pre-existing S4 method - but I really need to remove all at once.

Can check() and test() remove S4 methods on exit?

Garrett

@garrettgman
Copy link
Author

Here's more information. The problem disappears when I use check("lubridate", document = F). Also these combinations of code work:

test("lubridate")
test("lubridate")

document("lubridate", clean = TRUE)
document("lubridate", clean = TRUE)

and these do not. They give the error above

test("lubridate")
document("lubridate", clean = TRUE)

document("lubridate", clean = TRUE)
test("lubridate")

@hadley
Copy link
Member

hadley commented Feb 8, 2012

Even more minimally:

load_all("lubridate")
document("lubridate")

which is presumably happening because we get two sets of classes defined in two different environments.

@hadley
Copy link
Member

hadley commented Feb 8, 2012

Probably the best solution to this is to run in a separate R instance, and some how manually capture the caches and save to disk.

@hadley
Copy link
Member

hadley commented Jul 26, 2012

Another approach

library(parallel)
safe_expr <- function(expr) mccollect(mcparallel(expr))[[1]]

safe_expr(a <- 1:10)
safe_expr(library(ggplot2))
a
qplot

@wch
Copy link
Member

wch commented Aug 10, 2012

Fixed in #126.

@wch wch closed this as completed Aug 10, 2012
@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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants