Skip to content

Commit

Permalink
special handling for covr in windows
Browse files Browse the repository at this point in the history
workaround for windows covr

revised detatch

revised again

and again

thrice revised
  • Loading branch information
bburns632 committed Apr 23, 2024
1 parent d0ba30a commit 5d1984e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/FunctionReporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5d1984e

Please sign in to comment.