[R-pkg-devel] CRAN packages suggesting other packages but not using them conditionally
On 12/12/20 5:50 PM, Duncan Murdoch wrote:
On 12/12/2020 4:08 p.m., Spencer Graves wrote:
Hi, Ben et al.: On 2020-12-12 13:43, Ben Bolker wrote:
? ? Apologies if I'm telling you something you already know: ? ? By default, fda::CRAN() uses the presence of environment variables matched by the regexp "^_R_" as a heuristic to decide whether it's being running on CRAN. ? ? testthat::skip_on_cran()? calls testthat::on_cran() to look for an environment variable called NOT_CRAN equal to "true". The devtools::check() machinery automatically sets this variable.
? > testthat::on_cran Error: 'on_cran' is not an exported object from 'namespace:testthat' ????? Besides, on my Mac, I get: ? > testthat:::on_cran() [1] TRUE ????? My Mac is NOT CRAN, and I don't want that function to return TRUE on my computer unless I explicitly run "R CMD check --on-cran".
? ? So: fda::CRAN() depends on breakable assumptions, defaults to FALSE in an empty environment.? skip_on_cran() defaults to TRUE in an empty environment (but defaults to FALSE in a devtools::check() environment).
????? If future changes break fda::CRAN, I will have to deal with it then. ????? I'd be happier if the CRAN maintainers would develop a procedure to make it easier for package maintainers do two things: ??????????? * Include tests in their package that run longer than the time limit permitted on CRAN.
That's very easy now.? Just put them in a "slowtests" directory, and tell R CMD check to use that.? How could it be easier?
How would you do that? In "R CMD check --help" I see that one can use --test-dir= to specify the test directory, but I don't see a way to specify _additional_ test directories; short of setting a tests/ directory with CRAN-specific tests and a slowtests/ directory with *both* CRAN-specific and CRAN-excluded tests (thus duplicating files, which seems clunky), I don't see how to do this within a standard R CMD check framework (without testing a CRAN-indicating environment variable, which gets us back where we started ...) Or would you run R CMD check twice, once without and once with --test-dir=slowtests ? There doesn't seem to be very much in "Writing R Extensions" about testing - a little bit in https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-subdirectories What am I missing? Just to clarify, the ideal would be to be able to designate a separate set of tests that were *not* run on CRAN, and to be able to run them in the same "R CMD check" pass as the CRAN-specific tests. There are a bunch of ways to achieve this, but I think Spencer is saying (and I agree) that it would be nice if it were there an official mechanism that made this easier (and it seems pretty easy if the CRAN maintainers were agreeable to the idea ...)
Duncan Murdoch
______________________________________________ R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel