Skip to content

Commit

Permalink
simplify patch per HW comments
Browse files Browse the repository at this point in the history
Note we use the 'test_dir' deprecation warning in
'test_files' as that line may be triggered from either
'test_file' or 'test_dir'.  In the docs 'test_file' is
described as 'a variant of test_dir()...' so it seems
ok for 'test_file' to trigger a deprecation warning
with 'test_dir' in it.
  • Loading branch information
brodieG committed Sep 30, 2020
1 parent 9270b0b commit e7733d5
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions R/test-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ test_dir <- function(path,
abort("No test files found")
}

if (!is_missing(wrap)) {
lifecycle::deprecate_warn("3.0.0", "test_dir(wrap = )")
}

want_parallel <- find_parallel(path, load_package, package)

if (is.null(reporter)) {
Expand All @@ -94,22 +98,6 @@ 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,
Expand Down Expand Up @@ -163,18 +151,18 @@ test_files <- function(test_dir,
env = NULL,
stop_on_failure = FALSE,
stop_on_warning = FALSE,
wrap = lifecycle::deprecated(),
wrap = TRUE,
load_package = c("none", "installed", "source"),
parallel = FALSE) {

if(is_missing(wrap)) {
if (is_missing(wrap)) {
wrap <- TRUE
}
if (!isTRUE(wrap)) {
lifecycle::deprecate_warn("3.0.0", "test_dir(wrap = )")
}

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
Expand Down

0 comments on commit e7733d5

Please sign in to comment.