On 2024-05-30 7:43 a.m., Ivan Krylov via R-package-devel wrote:
В Thu, 30 May 2024 11:12:05 +0200
Héctor Meleiro Suárez <hmelei...@gmail.com> пишет:

So why is this a problem? Is it that there are too many files aftes
examples and tests are run? or would this NOTE be an issue to CRAN
even if only one file was detected at the end?

This problem has two sides.

The side that R CMD check is giving you NOTEs about is that _examples
and tests_ are requried to keep the global state of the system intact.

Only some parts of the global state: examples can create variables in globalenv().

Duncan Murdoch

This includes all files on the computer: writing anywhere except the
tempdir() is prohibited, and even that must be done with care not to
overwrite anything and cleaned up afterwards.

(See https://cran.r-project.org/web/packages/policies.html and search
for "temporary directory".)

The side that's more subjective is that outside tests and examples,
code shouldn't be touching the filesystem without the user's
permission. Many functions (e.g. write.table()) have a legitimate need
to alter the filesystem. If the user would legitimately benefit from not
having to download the files again (including between R sessions), feel
free to follow the advice of Thierry Onkelinx and use
tools::R_user_dir(...), except in tests and examples.

Testing functions that access external resources over the Internet is
fraught with additional peril. Your examples and tests must not fail if
a download attempt fails, but your users will probably prefer your
functions to stop() with an exception on download failure. One way to
solve this problem is to make sure that the functions that fetch
anything from the Internet raise errors with a specific class set and
then to wrap all examples and tests in tryCatch(...,
yourpackage_Internet_error = function(e) message('Caught an error while
accessing an Internet resource: ', conditionMessage(e))). This way any
other unchecked errors (that your tests attempt to uncover) will still
surface.


______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to