diff --git a/DESCRIPTION b/DESCRIPTION index f4ba0e1..59bc1ec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", , "mark.padgham@email.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2172-5265")), diff --git a/R/load-and-clear-traces.R b/R/load-and-clear-traces.R index d075af3..2decf94 100644 --- a/R/load-and-clear-traces.R +++ b/R/load-and-clear-traces.R @@ -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: @@ -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, diff --git a/R/trace-package.R b/R/trace-package.R index 79db5e6..67c385f 100644 --- a/R/trace-package.R +++ b/R/trace-package.R @@ -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) { @@ -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") } } @@ -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) + } +} diff --git a/codemeta.json b/codemeta.json index 1dac91e..8062523 100644 --- a/codemeta.json +++ b/codemeta.json @@ -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",