Skip to content

Commit

Permalink
add exclude & functions param to typetracer for #76
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Aug 26, 2022
1 parent f783c8d commit f6ec03a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: autotest
Title: Automatic Package Testing
Version: 0.0.2.196
Version: 0.0.2.197
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand Down
26 changes: 20 additions & 6 deletions R/typetrace-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,43 @@ get_typetrace_dir <- function () {
return (td)
}

autotest_trace_package <- function (package) {
autotest_trace_package <- function (package,
functions = NULL,
exclude = NULL) {

Sys.setenv ("TYPETRACER_LEAVE_TRACES" = "true")

package <- dot_to_package (package)
pkg_name <- preload_package (package)

exclude <- exclude_functions (package, functions, exclude)
if (!is.null (exclude)) {
functions <- ls (paste0 ("package:", pkg_name))
functions <- functions [which (!functions %in% exclude)]
}

Sys.setenv ("TYPETRACER_LEAVE_TRACES" = "true")
if (pkg_name != package) {
if (!dir.exists (package)) {
stop ("'package' should be a local directory.")
}
traces <- typetracer::trace_package (pkg_dir = package)
args <- list (pkg_dir = package)
} else {
traces <- typetracer::trace_package (package = package)
args <- list (package = package)
}
if (!is.null (functions)) {
args$functions = functions
}

traces <- do.call (typetracer::trace_package, args)

Sys.unsetenv ("TYPETRACER_LEAVE_TRACES") # traces are still there

trace_files <- list.files (
get_typetrace_dir (),
pattern = "^typetrace\\_.*\\.Rds$",
full.names = TRUE
)

Sys.unsetenv ("TYPETRACER_LEAVE_TRACES")

return (trace_files)
}

Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/autotest",
"issueTracker": "https://github.com/ropensci-review-tools/autotest/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.2.196",
"version": "0.0.2.197",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit f6ec03a

Please sign in to comment.