diff --git a/tests/testthat/test-failure-output.R b/tests/testthat/test-failure-output.R index 0033ea71f..cbfa41fd7 100644 --- a/tests/testthat/test-failure-output.R +++ b/tests/testthat/test-failure-output.R @@ -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)) @@ -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))