Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore test_dir(..., wrap = FALSE) #1183

Merged
merged 9 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
) {

Expand Down
21 changes: 17 additions & 4 deletions R/test-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = )")
}

Expand All @@ -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
)
Expand Down Expand Up @@ -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 {
Expand All @@ -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
)
}
Expand All @@ -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,
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down