Skip to content

Commit b01aa0b

Browse files
dgkfjimhester
authored andcommitted
handle case where coverage object has 0 tests
Previously, the $tests element being non-null was used to indicate that a coverage object was produced without tests. However, if no test were executed, these coverage traces may still need to be pruned of allocated, but unused matrix rows. Also migrated default test index from '0' to 'NA_integer_'. In nearly all cases this will have no effect, but has been rarely observed for tests which perform interrupts.
1 parent 2589c64 commit b01aa0b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

R/covr.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,8 @@ merge_coverage.list <- function(coverage_objs) {
642642
# may have been allocated, but not entirely populated.
643643
#
644644
clean_coverage_tests <- function(obj) {
645-
if (is.null(obj$tests)) return()
645+
counter_has_tests_tally <- function(counter) !is.null(counter$tests)
646+
if (is.na(Position(counter_has_tests_tally, obj))) return()
646647

647648
for (i in seq_along(obj)) {
648649
if (is.null(val <- obj[[i]]$value)) next

R/trace_tests.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ new_test_counter <- function(key) {
145145
.counters[[key]]$tests$.data <- vector("integer", 3L)
146146
.counters[[key]]$tests$.value <- integer(1L)
147147
.counters[[key]]$tests$tally <- matrix(
148-
0L,
148+
NA_integer_,
149149
ncol = 3L,
150150
# initialize with 4 empty rows, only expanded once populated
151151
nrow = 4L,

0 commit comments

Comments
 (0)