Skip to content
Prev 5552 / 12125 Next

[R-pkg-devel] email misleading: checking CRAN incoming feasibility ... NOTE Maintainer

Hi Spencer,

the NOTE you posted in your email was related to examples, so you probably don't need to remove tests. You can wrap part of the examples in \dontrun{} to reduce check time for examples.

As for tests, there are several ways of skipping (long-running) tests on CRAN. If you're using testthat, you typically have code chunks like this in your test-files:

  test_that("my_function", {
    expect_false(...)
    expect_equal(...)
  })

Just insert a "testthat::skip_on_cran()" as first line in that code-chunk:

  test_that("my_function", {
    skip_on_cran()
    expect_false(...)
    expect_equal(...)
  })

This will skip this particular test.

Another way if you want to run a complete test-file only locally depends on versioning. I always use 4 decimals as version numbers for my packages in development, e.g. package_0.1.2.3, and on CRAN, only three decimals: package_0.1.3 (this related to the package version you define in the DESCRIPTION file). If you follow this rules, you can set a global environment variable in the main test file, when you use "testthat", you should insert following code (change package name accordingly) in "testthat.R":

if (length(strsplit(packageDescription("my_package")$Version, "\\.")[[1]]) > 3) {
  Sys.setenv("RunAllPkgTests" = "yes")
} else {
  Sys.setenv("RunAllPkgTests" = "no")
}

For versions on CRAN (i.e. version number like 0.1.0), the environment variable "RunAllPkgTests" is "no", for your local package with version number like 0.1.0.1 this would be "yes". Then you wrap your complete test file into an if-statement:

.runThisTest <- Sys.getenv("RunAllinsightTests") == "yes"

if (.runThisTest) {
  # ... all my tests here
}

Here's a practical example:
https://github.com/easystats/insight/blob/master/tests/testthat.R
https://github.com/easystats/insight/blob/master/tests/testthat/test-bigglm.R

And for skip_on_cran() / skip_on_travis:
https://github.com/easystats/insight/blob/cddc6df6783aae859f2b707dd5a938493bff3aaa/tests/testthat/test-spatial.R#L141

Hope this helps!

Best
Daniel

-----Urspr?ngliche Nachricht-----
Von: R-package-devel <r-package-devel-bounces at r-project.org> Im Auftrag von Spencer Graves
Gesendet: Montag, 8. Juni 2020 16:53
An: r-package-devel at r-project.org
Betreff: Re: [R-pkg-devel] email misleading: checking CRAN incoming feasibility ... NOTE Maintainer

Hi, Uwe et al.:


       What's the preferred way to eliminate tests on CRAN that the 
maintainer still wants to run on other platforms?


       For several years, I've been using "if(!fda::CRAN()){...}". I've 
been told that I should NOT do that, but it has worked for me, and I 
haven't found anything better.  I've recently seen 
"testthat::skip_on_cran(...)", but I have yet to understand enough of 
how it works to actually use it.


       Thanks,
       Spencer Graves
On 2020-06-08 09:43, stefano wrote:
______________________________________________
R-package-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

--

_____________________________________________________________________

Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg | www.uke.de
Vorstandsmitglieder: Prof. Dr. Burkhard G?ke (Vorsitzender), Joachim Pr?l?, Prof. Dr. Blanche Schwappach-Pignataro, Marya Verdel
_____________________________________________________________________

SAVE PAPER - THINK BEFORE PRINTING