Skip to content

Commit

Permalink
add trace_source column to result; closes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Sep 8, 2022
1 parent dd0a02f commit c949898
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
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.002
Version: 0.1.1.003
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand Down
5 changes: 4 additions & 1 deletion R/load-and-clear-traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ load_traces <- function (files = FALSE, quiet = FALSE) {
fn_name <- tr_i$fn_name
par_formals <- tr_i$formals
num_traces <- tr_i$num_traces
trace_source <- tr_i$source

tr_i <- tr_i [which (!names (tr_i) %in%
c ("fn_name", "formals", "num_traces"))]
c ("fn_name", "formals", "num_traces", "source"))]
fn_call_hash <- gsub ("^.*typetrace\\_|\\.Rds$", "", i)

# simple vector columns:
Expand All @@ -51,6 +53,7 @@ load_traces <- function (files = FALSE, quiet = FALSE) {
tibble::tibble (
trace_name = i,
trace_number = num_traces,
trace_source = trace_source,
fn_name = fn_name,
fn_call_hash = fn_call_hash,
par_name = par_name,
Expand Down
17 changes: 16 additions & 1 deletion R/trace-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ trace_package <- function (package = NULL,

if ("examples" %in% types) {
trace_names <- trace_package_exs (package, functions)
traces <- list_traces ()
traces_ex <- list_traces ()
add_trace_source (traces_ex, "examples")
}
if ("tests" %in% types) {
if (testthat_is_parallel (pkg_dir) && !pre_installed) {
Expand All @@ -66,6 +67,9 @@ trace_package <- function (package = NULL,
test_traces <- NULL
} else {
test_traces <- trace_package_tests (package, pkg_dir, pre_installed)
traces_test <- list_traces ()
traces_test <- traces_test [which (!traces_test %in% traces_ex)]
add_trace_source (traces_test, "tests")
}
}

Expand Down Expand Up @@ -359,3 +363,14 @@ join_test_trace_data <- function (traces, test_traces) {

return (traces)
}

add_trace_source <- function (traces, trace_source) {

checkmate::assert_character (trace_source)

for (i in traces) {
tr <- readRDS (i)
tr$source <- trace_source
saveRDS (tr, i)
}
}
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/mpadge/typetracer",
"issueTracker": "https://github.com/mpadge/typetracer/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.1.002",
"version": "0.1.1.003",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit c949898

Please sign in to comment.