Skip to content

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

3 messages · Rolf Turner, Duncan Murdoch

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

cheers,

Rolf Turner
#
On 19/10/2023 8:17 p.m., Rolf Turner wrote:
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
#
On Fri, 20 Oct 2023 05:34:26 -0400
Duncan Murdoch <murdoch.duncan at gmail.com> wrote:

            
Ah-ha!  Good thinking!  Thanks, Duncan.

cheers,

Rolf