diff --git a/DESCRIPTION b/DESCRIPTION index 1d32aa08..72f16867 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Encoding: UTF-8 Package: covr Title: Test Coverage for Packages -Version: 3.6.5.9000 +Version: 3.6.5.9001 Authors@R: c( person("Jim", "Hester", email = "james.f.hester@gmail.com", role = c("aut", "cre")), person("Willem", "Ligtenberg", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index a62d0409..653fed7e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # covr (development version) +* Fix a rare edge case where `count_test` was called before `.current_test` has + been initialized leading to crash (@maksymiuks). + # covr 3.6.5 ## New Features and improvements diff --git a/R/trace_tests.R b/R/trace_tests.R index cf9f4af0..dcf46fbd 100644 --- a/R/trace_tests.R +++ b/R/trace_tests.R @@ -114,6 +114,11 @@ count_test <- function(key) { tests$tally <- rbind(tests$tally, matrix(NA_integer_, ncol = 4L, nrow = n)) } + # ignore if .current_test was not initialized properly yet + if (length(.current_test$index) == 0) { + return() + } + # test number tests$.data[[1L]] <- .current_test$index