Conditionally stop testing a tinytest test file if running under covr. This is determined by checking if

  • R is in a non-interactive session, and

  • the environment variable “NOT_CRAN” is unset or is not a TRUE value

skip_on_cran()

exit_on_cran()

Value

If called within a tinytest test running on CRAN in a non-interactive session, triggers an exit condition; otherwise, either a string saying “On CRAN” or NULL invisibly

“Skip” vs “Exit”

tinyexpect provides both “skip_” and “exit_” versions of “stop testing” functions due to the different philosophies of tinytest and testthat; in testthat, tests are encapsulated by test_that() to create smaller testing units within a single test file. As such, if a series of tests need to be passed over for some reason, it makes sense to “skip” a test_that() block and move on to the next block

tinytest, however, treats each test file as a testing unit. Each file in inst/tinytest is equivalent to a testthat test_that() block; as such, if a series of tests need to be passed over for some reason, it makes sense to “exit” a test file and move on to the next file in inst/tinytest

In order to provide compatibility with users transitioning from testthat to tinytest, and to provide continuity with the tinytest philosophy, tinyexpect provides both skip_- and exit_- prefixed “stop testing” functions that work identically to one another

Examples

withr::with_envvar(c(NOT_CRAN = "false"), skip_on_cran())
#> [1] "On CRAN"