Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
New function to skip check() but run test() (#347)
Browse files Browse the repository at this point in the history
This allows using here::here() in tests.
  • Loading branch information
maurolepore authored Nov 24, 2020
1 parent cda2fd4 commit 1b92b87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/testthat/helper-skip_check_but_run_test.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
skip_check_but_run_test <- function() {
testthat::skip_if_not(
fs::file_exists(here::here(".pacta")),
"Source code is unavailable"
)
}
11 changes: 11 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ test_that("use_r_packages() puts listed packages on search() path", {
expect_true(is_attached(package))
}
})

test_that("helper skip_check_but_run_test() works as expected", {
# This test should not be skipped during devtools::test()
# This test should be skipped during devtools::check()
# If you remove `skip_check_but_run_test()`, devtools::check() should error
skip_check_but_run_test()

# This file should be available only when the source code is accessible, i.e.
# not during R CMD check, when the code runs from the system installation
expect_true(fs::file_exists(here::here(".pacta")))
})

0 comments on commit 1b92b87

Please sign in to comment.