Skip to content

Commit

Permalink
Fix test case in R CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Aug 8, 2024
1 parent e113055 commit 127003a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/testthat/test-failure-output.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ test_that("output is printed on failure", {

expect_error(
callr::r(stdout = tmp, stderr = tmp, function(pkg) {
pkgload::load_all()
# if this is not R CMD check, use `load_all()``
# otherwise `load_all()` does not work, because we are not in the
# package tree in `R CMD check`.
if (Sys.getenv("_R_CHECK_PACKAGE_NAME_") == "") pkgload::load_all()
options(rlib_interactive = TRUE)
pak::pkg_install(pkg)
}, list(pkg = badcompile))
Expand All @@ -28,7 +31,8 @@ test_that("output is printed on failure", {

expect_error(
callr::r(stdout = tmp, stderr = tmp, function(pkg) {
pkgload::load_all()
# see above
if (Sys.getenv("_R_CHECK_PACKAGE_NAME_") == "") pkgload::load_all()
options(rlib_interactive = FALSE)
pak::pkg_install(pkg)
}, list(pkg = badcompile))
Expand Down

0 comments on commit 127003a

Please sign in to comment.