Skip to content

Commit

Permalink
dump 'trace_file' and 'call_env' in to trace results for #14
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Jun 21, 2023
1 parent 5bb87bb commit ce701b8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 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.014
Version: 0.1.1.015
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand Down
12 changes: 12 additions & 0 deletions R/load-and-clear-traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,22 @@ load_traces <- function (files = FALSE, quiet = FALSE) {
par_uneval <- I (lapply (tr_i, function (i) i$par_uneval))
par_eval <- I (lapply (tr_i, function (i) i$par_eval))

call_envs <- do.call (rbind, lapply (tr_i, function (i) {
ci <- i$call_envs
if (nrow (ci) == 0L) {
ci <- ci [1, ] # auto-fills with NA
}
return (ci)
}))
call_envs$call_env <- paste0 (call_envs$namespace, "::", call_envs$name)
call_envs$call_env [which (is.na (call_envs$name))] <- NA_character_

tibble::tibble (
trace_name = i,
trace_number = num_traces,
trace_source = trace_source,
trace_file = call_envs$file,
call_env = call_envs$call_env,
fn_name = fn_name,
fn_call_hash = fn_call_hash,
par_name = par_name,
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"codeRepository": "https://github.com/mpadge/typetracer",
"issueTracker": "https://github.com/mpadge/typetracer/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.1.014",
"version": "0.1.1.015",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-trace-fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ test_that ("trace call", {

expect_s3_class (x, "tbl_df")
expect_equal (nrow (x), 2L) # x and y
expect_equal (ncol (x), 13L)
expect_equal (ncol (x), 15L)
expect_identical (
names (x),
c (
"trace_name", "trace_number", "fn_name",
"fn_call_hash", "par_name", "class",
"typeof", "mode", "storage_mode", "length",
"trace_name", "trace_number",
"trace_file", "call_env",
"fn_name", "fn_call_hash", "par_name",
"class", "typeof", "mode", "storage_mode", "length",
"formal", "uneval", "eval"
)
)
Expand Down
15 changes: 9 additions & 6 deletions tests/testthat/test-trace-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ test_that ("trace installed package", {
expect_identical (
names (x0),
c (
"trace_number", "trace_source", "fn_name",
"fn_call_hash", "par_name", "class",
"trace_number", "trace_source",
"trace_file", "call_env",
"fn_name", "fn_call_hash", "par_name", "class",
"typeof", "mode", "storage_mode", "length",
"formal", "uneval", "eval", "source"
)
Expand All @@ -46,8 +47,9 @@ test_that ("trace installed package", {
expect_identical (
names (x1),
c (
"trace_number", "trace_source", "fn_name",
"fn_call_hash", "par_name", "class",
"trace_number", "trace_source",
"trace_file", "call_env",
"fn_name", "fn_call_hash", "par_name", "class",
"typeof", "mode", "storage_mode", "length",
"formal", "uneval", "eval", "source"
)
Expand Down Expand Up @@ -91,8 +93,9 @@ test_that ("trace source package", {
expect_identical (
names (x0),
c (
"trace_number", "trace_source", "fn_name",
"fn_call_hash", "par_name", "class",
"trace_number", "trace_source",
"trace_file", "call_env",
"fn_name", "fn_call_hash", "par_name", "class",
"typeof", "mode", "storage_mode", "length",
"formal", "uneval", "eval", "source"
)
Expand Down

0 comments on commit ce701b8

Please sign in to comment.