-
Notifications
You must be signed in to change notification settings - Fork 323
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
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2a1baea
initial cut at adding 'wrap'
brodieG a25662b
default wrap to TRUE
brodieG c1c1663
move 'wrap' checks to 'test_dir'
brodieG ac12922
revert unintentional test modification
brodieG 11fb111
fix comment
brodieG 9270b0b
fix partial match
brodieG e7733d5
simplify patch per HW comments
brodieG bbc7d3c
remove partial match fix
brodieG a6c3660
Merged origin/master into brodieG-restore-wrap
hadley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,10 +82,6 @@ test_dir <- function(path, | |
abort("No test files found") | ||
} | ||
|
||
if (!missing(wrap)) { | ||
lifecycle::deprecate_warn("3.0.0", "test_dir(wrap = )") | ||
} | ||
|
||
want_parallel <- find_parallel(path, load_package, package) | ||
|
||
if (is.null(reporter)) { | ||
|
@@ -98,6 +94,22 @@ test_dir <- function(path, | |
reporter <- find_reporter(reporter) | ||
parallel <- want_parallel && reporter$capabilities$parallel_support | ||
|
||
if (parallel) { | ||
if (!is_missing(wrap)) { | ||
lifecycle::deprecate_stop( | ||
"3.0.0", "test_dir(wrap = )", | ||
details=paste0( | ||
"`wrap = ` may only be used with serial tests, but detected that ", | ||
"parallel tests requested." | ||
) | ||
) | ||
} | ||
} else { | ||
if (!is_missing(wrap)) { | ||
lifecycle::deprecate_warn("3.0.0", "test_file(wrap = )") | ||
} | ||
} | ||
|
||
test_files( | ||
test_dir = path, | ||
test_paths = test_paths, | ||
|
@@ -107,6 +119,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,10 +163,18 @@ test_files <- function(test_dir, | |
env = NULL, | ||
stop_on_failure = FALSE, | ||
stop_on_warning = FALSE, | ||
wrap = lifecycle::deprecated(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
load_package = c("none", "installed", "source"), | ||
parallel = FALSE) { | ||
|
||
if(is_missing(wrap)) { | ||
wrap <- TRUE | ||
} | ||
if (parallel) { | ||
if(!isTRUE(wrap)) { | ||
warning('`wrap` must be TRUE in parallel mode.') | ||
wrap <- TRUE | ||
} | ||
test_files <- test_files_parallel | ||
} else { | ||
test_files <- test_files_serial | ||
|
@@ -168,6 +189,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 +202,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 +275,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() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that you're the only person using this argument, I think you can just keep the warning the same for both serial and parallel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I did this. If for whatever reason someone ends up using
wrap=FALSE
in parallel mode they might be confused, but given they will get a deprecation warning hopefully they'll figure it out, and more likely such a person won't exist anyway.