From 4dee774a8ba56b1586f2f8fec933ebd9f9749b2d Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Fri, 23 Aug 2024 15:28:30 -0500 Subject: [PATCH 1/2] Rely on `load_all()` to load helpers Otherwise effectively unload them for the developer. Fixes #1982 --- R/test-files.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/test-files.R b/R/test-files.R index 362ccd85c..23b58128d 100644 --- a/R/test-files.R +++ b/R/test-files.R @@ -197,6 +197,15 @@ test_files_serial <- function(test_dir, load_package = c("none", "installed", "source"), error_call = caller_env()) { + # Because load_all() called by test_files_setup_env() will have already + # loaded them. We don't want to rely on testthat's loading since that + # only affects the test environment and we want to keep the helpers + # looded in the users session. + load_package <- arg_match(load_package) + if (load_package == "source") { + load_helpers <- FALSE + } + env <- test_files_setup_env(test_package, test_dir, load_package, env) # record testing env for mocks local_testing_env(env) @@ -244,7 +253,7 @@ test_files_setup_env <- function(test_package, } find_load_all_args <- function(path) { - default <- list(export_all = TRUE, helpers = FALSE) + default <- list(export_all = TRUE, helpers = TRUE) desc <- find_description(path) if (is.null(desc)) { From f18a03756e8b0c27962dd5079a995a210024e818 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 23 Oct 2024 08:15:03 -0500 Subject: [PATCH 2/2] Update R/test-files.R Co-authored-by: Davis Vaughan --- R/test-files.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/test-files.R b/R/test-files.R index 23b58128d..397fb2dc6 100644 --- a/R/test-files.R +++ b/R/test-files.R @@ -200,7 +200,7 @@ test_files_serial <- function(test_dir, # Because load_all() called by test_files_setup_env() will have already # loaded them. We don't want to rely on testthat's loading since that # only affects the test environment and we want to keep the helpers - # looded in the users session. + # loaded in the user's session. load_package <- arg_match(load_package) if (load_package == "source") { load_helpers <- FALSE