diff --git a/R/parallel.R b/R/parallel.R index 1d540bb87..38362f4a8 100644 --- a/R/parallel.R +++ b/R/parallel.R @@ -41,6 +41,7 @@ test_files_parallel <- function( env = NULL, stop_on_failure = FALSE, stop_on_warning = FALSE, + wrap = TRUE, # unused, to match test_files signature load_package = c("none", "installed", "source") ) { diff --git a/R/test-files.R b/R/test-files.R index 14c2aa452..6e03ddafb 100644 --- a/R/test-files.R +++ b/R/test-files.R @@ -82,7 +82,7 @@ test_dir <- function(path, abort("No test files found") } - if (!missing(wrap)) { + if (!is_missing(wrap)) { lifecycle::deprecate_warn("3.0.0", "test_dir(wrap = )") } @@ -107,6 +107,7 @@ test_dir <- function(path, env = env, stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, + wrap = wrap, load_package = load_package, parallel = parallel ) @@ -150,9 +151,17 @@ test_files <- function(test_dir, env = NULL, stop_on_failure = FALSE, stop_on_warning = FALSE, + wrap = TRUE, load_package = c("none", "installed", "source"), parallel = FALSE) { + if (is_missing(wrap)) { + wrap <- TRUE + } + if (!isTRUE(wrap)) { + lifecycle::deprecate_warn("3.0.0", "test_dir(wrap = )") + } + if (parallel) { test_files <- test_files_parallel } else { @@ -168,6 +177,7 @@ test_files <- function(test_dir, env = env, stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, + wrap = wrap, load_package = load_package ) } @@ -180,13 +190,16 @@ test_files_serial <- function(test_dir, env = NULL, stop_on_failure = FALSE, stop_on_warning = FALSE, + wrap = TRUE, load_package = c("none", "installed", "source")) { env <- test_files_setup_env(test_package, test_dir, load_package, env) test_files_setup_state(test_dir, test_package, load_helpers, env) reporters <- test_files_reporter(reporter) - with_reporter(reporters$multi, lapply(test_paths, test_one_file, env = env)) + with_reporter(reporters$multi, + lapply(test_paths, test_one_file, env = env, wrap = wrap) + ) test_files_check(reporters$list$get_results(), stop_on_failure = stop_on_failure, @@ -250,12 +263,12 @@ test_files_check <- function(results, stop_on_failure = TRUE, stop_on_warning = invisible(results) } -test_one_file <- function(path, env = test_env()) { +test_one_file <- function(path, env = test_env(), wrap = TRUE) { reporter <- get_reporter() on.exit(teardown_run(), add = TRUE) reporter$start_file(path) - source_file(path, child_env(env)) + source_file(path, child_env(env), wrap = wrap) reporter$end_context_if_started() reporter$end_file() } diff --git a/R/utils.R b/R/utils.R index 3933ce4f1..6b40964cc 100644 --- a/R/utils.R +++ b/R/utils.R @@ -71,7 +71,7 @@ remove_source <- function(x) { } } -# Need to stip environment and source references to make lightweight +# Need to strip environment and source references to make lightweight # function suitable to send to another process transport_fun <- function(f) { environment(f) <- .GlobalEnv