r-lib / covr
Showing 2 of 6 files from the diff.

@@ -18,10 +18,11 @@
Loading
18 18
#'     execution.
19 19
#'
20 20
#'   \item `$<srcref>$tests`: For each srcref count in the coverage object, a
21 -
#'     `$tests` field is now included which contains a matrix with two columns,
22 -
#'     "test" and "depth" which specify the test number (corresponding to the
23 -
#'     index of the test in `attr(,"tests")` and the stack depth into the target
24 -
#'     code where the trace was executed.
21 +
#'     `$tests` field is now included which contains a matrix with three columns,
22 +
#'     "test", "depth" and "i" which specify the test number (corresponding to the
23 +
#'     index of the test in `attr(,"tests")`, the stack depth into the target
24 +
#'     code where the trace was executed, and the order of execution for each
25 +
#'     test.
25 26
#' }
26 27
#'
27 28
#' @section Test traces:
@@ -48,7 +49,7 @@
Loading
48 49
#' fcode <- '
49 50
#' f <- function(x) {
50 51
#'   if (x)
51 -
#'     TRUE
52 +
#'     f(!x)
52 53
#'   else
53 54
#'     FALSE
54 55
#' }'
@@ -56,20 +57,34 @@
Loading
56 57
#' options(covr.record_tests = TRUE)
57 58
#' cov <- code_coverage(fcode, "f(TRUE)")
58 59
#'
59 -
#' # extract executed tests traces
60 -
#' attr(cov, "tests")
61 -
#' # $`/tmp/test.R:1:1:1:7:1:7:1:1`
62 -
#' # $`/tmp/test.R:1:1:1:7:1:7:1:1`[[1]]
60 +
#' # extract executed test code for the first test
61 +
#' tail(attr(cov, "tests")[[1L]], 1L)
62 +
#' # [[1]]
63 63
#' # f(TRUE)
64 64
#'
65 65
#' # extract test itemization per trace
66 66
#' cov[[3]][c("srcref", "tests")]
67 67
#' # $srcref
68 -
#' # TRUE
68 +
#' # f(!x)
69 69
#' #
70 70
#' # $tests
71 -
#' #      test depth
72 -
#' # [1,]    1     1
71 +
#' #      test depth i
72 +
#' # [1,]    1     2 4
73 +
#'
74 +
#' # reconstruct the code path of a test by ordering test traces by [,"i"]
75 +
#' lapply(cov, `[[`, "tests")
76 +
#' # $`source.Ref2326138c55:4:6:4:10:6:10:4:4`
77 +
#' #      test depth i
78 +
#' # [1,]    1     1 2
79 +
#' # 
80 +
#' # $`source.Ref2326138c55:3:8:3:8:8:8:3:3`
81 +
#' #      test depth i
82 +
#' # [1,]    1     1 1
83 +
#' # [2,]    1     2 3
84 +
#' # 
85 +
#' # $`source.Ref2326138c55:6:6:6:10:6:10:6:6`
86 +
#' #      test depth i
87 +
#' # [1,]    1     2 4
73 88
#'
74 89
#' @name covr.record_tests
75 90
NULL
@@ -88,10 +103,11 @@
Loading
88 103
  # ignore if .counter was not created with record_tests (nested coverage calls)
89 104
  if (is.null(.counters[[key]]$tests)) return()
90 105
91 -
  depth_into_pkg <- length(sys.calls()) - .current_test$frame - n_calls_into_covr + 1L
106 +
  depth_into_pkg <- length(sys.calls()) - length(.current_test$frames) - n_calls_into_covr + 1L
107 +
  .current_test$i <- .current_test$i + 1L
92 108
  .counters[[key]]$tests <- rbind(
93 109
    .counters[[key]]$tests,
94 -
    c(length(.counters$tests), depth_into_pkg)
110 +
    c(length(.counters$tests), depth_into_pkg, .current_test$i)
95 111
  )
96 112
}
97 113
@@ -146,6 +162,7 @@
Loading
146 162
147 163
  # build updated current test data, isolating relevant frames
148 164
  .current_test$trace <- syscalls[exec_frames]
165 +
  .current_test$i <- 0L
149 166
  .current_test$frames <- exec_frames
150 167
  .current_test$last_frame <- exec_frames[[Position(
151 168
    has_srcref,

@@ -117,8 +117,9 @@
Loading
117 117
  if (isTRUE(getOption("covr.record_tests", FALSE))) {
118 118
    .counters[[key]]$tests <- matrix(
119 119
      numeric(0L),
120 -
      ncol = 2,
121 -
      dimnames = list(c(), c("test", "depth")))
120 +
      ncol = 3L,
121 +
      # test index; call stack depth of covr:::count; execution order index
122 +
      dimnames = list(c(), c("test", "depth", "i")))
122 123
  }
123 124
124 125
  key
Files Coverage
R 78.10%
src/reassign.c 100.00%
Project Totals (28 files) 78.29%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
1
comment: false
2

3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: auto
8
        threshold: 1%
9
        informational: true
10
    patch:
11
      default:
12
        target: auto
13
        threshold: 1%
14
        informational: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading