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

Rolf Turner ro||turner @end|ng |rom po@teo@net
Sat Oct 21 00:43:39 CEST 2023


On Fri, 20 Oct 2023 05:34:26 -0400
Duncan Murdoch <murdoch.duncan using gmail.com> wrote:

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

Ah-ha!  Good thinking!  Thanks, Duncan.

cheers,

Rolf


-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
         +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619




More information about the R-package-devel mailing list