Skip to content

Commit

Permalink
Improve error message when report dependencies missing
Browse files Browse the repository at this point in the history
A number of people have been confused by this, so we might as well add
code to make it more clear

Fixes #500
  • Loading branch information
jimhester committed Feb 2, 2022
1 parent 94de459 commit 896ee39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# covr (development version)

* `report()` now provides a more detailed error message if the `DT` and `htmltools` dependencies are not installed (#500).

* Added `covr.record_tests` option. When `TRUE`, this enables the recording of
the trace of the tests being executed and adds an itemization of which tests
result in the execution of each trace. For more details see
Expand Down
5 changes: 3 additions & 2 deletions R/report.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ report <- function(x = package_coverage(),
# Paths need to be absolute for save_html to work properly
file <- file.path(normalizePath(dirname(file), mustWork = TRUE), basename(file))

loadNamespace("htmltools")
loadNamespace("DT")
if (!(requireNamespace("htmltools", quietly = TRUE) && requireNamespace("DT", quietly = TRUE))) {
stop("The `DT` and `htmltools` packages must be installed to use `covr::report()`", call. = FALSE)
}

data <- to_report_data(x)

Expand Down

0 comments on commit 896ee39

Please sign in to comment.