[R-pkg-devel] \donttest{} and writing outputs to tempdir()
Spencer Graves
@pencer@gr@ve@ @end|ng |rom e||ect|vede|en@e@org
Wed Jun 2 17:08:48 CEST 2021
You surely should be able to have some examples that would run in
less than 5 seconds.
I almost never use "donttest". Instead I use conditional skips, and
those only on examples that I believe are likely to run too long. In
those cases, I believe the standard recommendation is:
testthat::skip_on_cran
https://testthat.r-lib.org/reference/skip.html
HOWEVER: To use this, users must manually set Sys.getenv("NOT_CRAN") to
"true" if they want the tests to run in environments that are not CRAN.
I don't perceive the documentation on this to be adequate; I'd rather
not have to set an environment variable in every new environment that
I'd like to have run all the tests. Therefore, some years ago, I added
a CRAN function to the fda package, which I use as follows:
if(!fda::CRAN()){
# code I don't want to run on CRAN
# but do want to run elsewhere.
# You can use:
# R CMD check --as-cran
# to see if it works OK on CRAN
}
Spencer
On 6/2/21 12:29 AM, Jeff Newmiller wrote:
> Make examples shorter so they can run faster. Wrapping everything in donttest means that running examples() does nothing, which is counterproductive.
>
> Techinically, vignettes are not tests or examples... but they do have the advantage that they don't have to run quickly. But that doesn't make a vignette a substitute for either examples or tests.
>
> As for writing to the wrong place, you should probably just double check.
>
> On June 1, 2021 9:39:43 PM PDT, Danielle Maeser <maese005 using umn.edu> wrote:
>> Hello,
>>
>> I received the following comments from a CRAN maintainer, and I don't
>> understand why they were an issue. I'd appreciate any insight you can
>> provide.
>>
>> Danielle
>>
>>
>>
>>
>>
>>
>>
>> *All your examples are wrapped in \donttest{} and therefore do not
>> gettested.Please unwrap the examples if that is feasible and if they
>> can
>> beexecuted in < 5 sec for each Rd file or create additionally small
>> toyexamples to allow automatic testing.*
>>
>> I don't think I can unwrap the examples in \donttest{} because they
>> cannot
>> be executed in <5 seconds for each Rd file, and the automatic testing
>> of
>> toy data is satisfied in the vignettes I provide for each function.
>> Therefore, I am not sure what change to make here.
>>
>>
>>
>>
>> *Please ensure that your functions do not write by default or in
>> yourexamples/vignettes/tests in the user's home filespace (including
>> thepackage directory and getwd()). This is not allowed by CRAN
>> policies.In
>> your examples/vignettes/tests you can write to tempdir().*
>>
>> Additionally, all of my vignettes write the output of each function to
>> tempdir(). Therefore, I am not sure why this is a problem.
>
More information about the R-package-devel
mailing list