From 127003a6b9700d457199001cea1d1e9a35a17f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Cs=C3=A1rdi?= Date: Thu, 8 Aug 2024 13:15:25 +0200 Subject: [PATCH] Fix test case in R CMD check --- tests/testthat/test-failure-output.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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))