diff --git a/R/FunctionReporter.R b/R/FunctionReporter.R index 32b7c95..9414848 100644 --- a/R/FunctionReporter.R +++ b/R/FunctionReporter.R @@ -151,12 +151,24 @@ FunctionReporter <- R6::R6Class( log_info(sprintf("Calculating test coverage for %s...", self$pkg_name)) + # workaround for covr conflict with loaded packages on windows + if(.Platform$OS.type == "windows") { + detach(paste0('package:',self$pkg_name), unload = TRUE, character.only = TRUE) + } + pkgCovDT <- data.table::as.data.table(covr::package_coverage( path = private$pkg_path , type = "tests" , combine_types = FALSE + , quiet = FALSE + , clean = FALSE )) + # workaround for covr conflict with loaded packages on windows + if(.Platform$OS.type == "windows") { + attachNamespace(self$pkg_name) + } + pkgCovDT <- pkgCovDT[, .(coveredLines = sum(value > 0) , totalLines = .N , coverageRatio = sum(value > 0)/.N