Usethis: default to not running spell check tests on CRAN servers

Created on 5 Jul 2018  路  11Comments  路  Source: r-lib/usethis

I have been using usethis::use_spell_check() to check spellings. But this creates a test that is good to run locally but not suitable for CRAN. My package has been rejected twice because of the spelling tests with the following comment-

why do you run spell check in the tests?

Spelling won't change, hence no need to run that daily on several
machines on CRAN. Just do it once prior to submission.

In tests, the idea is to check whether your package is calculating
correctly which may change due to changes on the operating systems, in
R, or package dependencies.

What can I do to not run this test on CRAN servers? I tried adding tests\^spelling to .Rbuildignore file, but the test still runs on CRAN. It iwill be good to have defaults that avoid this issue altogether. Because, as pointed out by CRAN members, spellings are not changing on a daily basis and this is a waste computational resources.

Most helpful comment

Borrowing from testthat::skip_on_cran(), try:

if (identical(Sys.getenv("NOT_CRAN"), "true")) {
  spelling::spell_check_test(vignettes = TRUE, error = FALSE)
}

All 11 comments

Pilfering this from Karl Broman's R package primer:

Computationally intensive code could also be placed in \dontrun{ } or \donttest{ }. Code in \dontrun{ } will never be run automatically; code in\donttest{ } will be run when a user calls example( ) but won鈥檛 be run with R CMD.

Looking at the code inside usethis itself, here's the internal setup.
https://github.com/r-lib/usethis/blob/1a04c1487eb094ce82ee1b0cb741f311113257bb/tests/spelling.R

Thanks, Mara. But I am still not sure how to prevent R CMD CHECK from running spell check tests. Should I do the following?

\donttest{spelling::spell_check_test(vignettes = TRUE, error = FALSE)}

I believe that would keep R CMD Check from running it, but it would also not run automatically for you.
Hopefully someone else with more experience with this (so, anyone, really) will weigh in. Just thought Karl's tips were nice options!

Borrowing from testthat::skip_on_cran(), try:

if (identical(Sys.getenv("NOT_CRAN"), "true")) {
  spelling::spell_check_test(vignettes = TRUE, error = FALSE)
}

cc @jeroen

Thanks. I'll update this in the template that spelling generates. For existing packages you should just modify this in the tests/spelling.R file in the package that you are spell checking, which is what gets run during CMD check.

Oh sorry I didn't mean to close this, that happened by accident due to the commit message.

Spelling 1.2 (released today) will by default skip all auto checking on CRAN.

@jeroen When I install spelling from CRAN, the spelling set up file still doesn't seem to include the condition re: the NOT_CRAN env var 馃

Oh now I see you backed out of that and implemented 'skip on cran' differently.

Yes I implemented it in the package itself. The function spell_check_test() will now always skip on CRAN by default: https://github.com/ropensci/spelling/blob/master/R/spell-check.R#L147-L152

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uribo picture uribo  路  5Comments

maxheld83 picture maxheld83  路  3Comments

hadley picture hadley  路  5Comments

aosmith16 picture aosmith16  路  5Comments

xrobin picture xrobin  路  7Comments