[R-pkg-devel] Switch between \dontrun{ } and \donttest{ }.

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Fri Oct 20 11:34:26 CEST 2023


On 19/10/2023 8:17 p.m., Rolf Turner wrote:
> 
> In a package that I maintain, there are examples, in the *.Rd files,
> that take an excruciatingly long time to run.  This makes package
> checking extremely tedious.  There is no question of errors being
> thrown from these examples, they are simply time consuming.  (The check
> is being run to look for possible errors elsewhere.)
> 
> I therefore would like to wrap these examples in \dontrun{ }.
> 
> However when the package is submitted to CRAN, it is expedient to wrap
> the examples in \donttest{ } rather than \dontrun{ }.
> 
> I would therefore like to find a means of effecting the following
> logical structure:
> 
>      if(package is being checked by CRAN) {
>          Use \donttest{ }
>      } else {
>          Use \dontrun{ }
>      }
> 
> Is there a reasonably straightforward means of detecting whether
> the package is being checked by CRAN, and thereby setting up such a
> logical structure? Perhaps based on environment variables?
> 
> Can anyone give me any guidance?  Thanks.

I think the method used by the testthat package is best:  assume it is 
being run by CRAN, unless an environment variable named NOT_CRAN is set 
to "true" (or some string like that).  Then set the environment variable 
at home, where you know you are not on CRAN.

Duncan




More information about the R-package-devel mailing list