[R-pkg-devel] How to reduce examples in a package that takes more than 5 seconds to run?

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Tue Dec 27 19:27:56 CET 2022


On 15/12/2022 10:25 a.m., Spencer Graves wrote:

> 	  The "sos" package includes a function "CRAN", which is used for that
> purpose.  The examples section in "findfn.Rd" includes the following:
> 
> 
> # Skip these tests on CRAN,
> # because they take more than 5 seconds
> if(!CRAN()){
> ...
> }
> 
> 
> 	  I know that some on this list do not like this construct, but it has
> helped me manage this problem for several years.  NOTE:  This CRAN
> function is NOT maintained by anyone on CRAN, so it is NOT guaranteed to
> work.  However, the "sos" package is currently on CRAN, and I have not
> seen an email asking me to avoid it ;-)

I've been reminded today why this is such a bad idea.  I'm preparing an 
update of the rgl package.  As I attempt to be a good citizen, I'm doing 
comparison checks of all of the 300 packages that use it, to see if my 
updates break anything.  I am not CRAN, so if any of those packages 
follow Spencer's scheme, I'll have to wait even longer for the run to 
finish.  (Currently it's about 15 hours predicted time on my slow laptop.)

It's more considerate to have a function that defaults to not running 
slow tests unless you specifically ask for them to be run.  The testthat 
package does this using the NOTCRAN environment variable:  it assumes 
everyone is CRAN unless they specifically declare themselves not to be. 
Strange choice of name, but it achieves what I'm suggesting.  The 
tinytest package has an "at_home" argument to some functions; when 
testing a whole package, it defaults to FALSE, which is also the 
considerate choice.

Duncan Murdoch



More information about the R-package-devel mailing list