I submitted a package to CRAN and they asked me to replace \dontrun{}
by \donttest{}
in the Rd-files and resubmit. I was using \dontrun{}
to wrap some examples that are supposed to throw error messages.
After replacing \dontrun{}
by \donttest{}
I conducted some tests and R CMD check
still succeeds but it happens that now both devtools::check()
and R CMD check --as-cran
fail due to the examples wrapped in \donttest{}
:
checking examples with --run-donttest ... ERROR
After some browsing I learned that R 4.0.0 has changed R CMD check --as-cran
to run \donttest
examples. According to the NEWS of R-devel:
"R CMD check --as-cran now runs \donttest examples (which are run by example()) instead of instructing the tester to do so. This can be temporarily circumvented during development by setting environment variable R_CHECK_DONTTEST_EXAMPLES to a false value."
Since I intend to resubmit the package to CRAN, setting _R_CHECK_DONTTEST_EXAMPLES_
to false
locally will not help me.
I also found this recent discussion in a devtools
issue where Hadley Wickham states that:
"Generally, now if you don't want to run tests on CRAN \dontrun{} is more likely to work, but using \dontrun{} may cause initial submission to fail."
So now I don't know how to proceed because if I resubmit the package with the required changes I already know it will throw an error in R CMD check --as-cran
, and hence it will probably fail CRAN's automatic pretests.
EDIT:
As suggested here I tried if(interactive()){}
instead of \dontrun{}
. This solution succeeds in R CMD check --as-cran
and devtools::check()
but I don't think it is the most appropriate way to address this problem since it does not work well with example()
(throws an error and does not show the remaining examples). \dontrun{}
works better with example()
as it prints all the examples but comments out the ones wrapped with \dontrun{}
.
[email protected]
mailing list ... it's an administrative question rather than a programming question ... – Rhythmif(interactive()){}
instead of\donttest{}
, as suggested here here – Lemniscusif(interactive())
in the lines of the exemples that i'm trying not to run, and in that sense\donttest{}
would result in "tidier" documentation since\donttest{}
is not printed. But I don't think\donttest{}
is an option here since it will return actual errors when runningR CMD check --as-cran
(and also when runningexample()
. But this is still an improvement when compared to\dontrun
because\dontrun
is also printed to the documentation. – Lemniscusif(interactive()){}
allows the user to run examples line by line since the condition evaluates toTRUE
.\donttest{}
is printed to the documentation and so the user has to select only the code that is inside the{}
, which is not so user friendly – Lemniscus