-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split testthat fns into R/testthat-fns.R
- Loading branch information
Showing
4 changed files
with
45 additions
and
44 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: typetracer | ||
Title: Trace Function Parameter Types | ||
Version: 0.1.1.001 | ||
Version: 0.1.1.002 | ||
Authors@R: c( | ||
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-2172-5265")), | ||
|
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
testthat_is_parallel <- function (pkg_dir) { | ||
|
||
flist <- list.files (pkg_dir, recursive = TRUE, full.names = TRUE) | ||
desc <- grep ("DESCRIPTION$", flist, value = TRUE) | ||
if (length (desc) != 1L) { | ||
return (FALSE) | ||
} | ||
desc <- read.dcf (desc) | ||
field <- "Config/testthat/parallel" | ||
if (!field %in% colnames (desc)) { | ||
return (FALSE) | ||
} | ||
ret <- as.logical (desc [1L, field]) | ||
ret <- ifelse (is.na (ret), FALSE, ret) | ||
|
||
return (ret) | ||
} | ||
|
||
#' Remove testthat "parallel = true" config entry from DESCRIPTION | ||
#' | ||
#' Tests can not be traced in parallel (issue#10), so this line needs to be | ||
#' removed in order to enable tracing. | ||
#' @noRd | ||
rm_testthat_parallel <- function (pkg_dir) { | ||
|
||
message ( | ||
"Tests can not be traced with testthat tests run in parallel; ", | ||
"parallel testing has been temporarily deactivated." | ||
) | ||
|
||
flist <- list.files (pkg_dir, recursive = TRUE, full.names = TRUE) | ||
desc_file <- grep ("DESCRIPTION$", flist, value = TRUE) | ||
if (length (desc_file) != 1L) { | ||
return (NULL) | ||
} | ||
desc <- brio::read_lines (desc_file) | ||
field <- "Config/testthat/parallel" | ||
desc <- desc [-grep (field, desc, fixed = TRUE)] | ||
|
||
brio::write_lines (desc, desc_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
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