Skip to content

Commit 896ee39

Browse files
committed
Improve error message when report dependencies missing
A number of people have been confused by this, so we might as well add code to make it more clear Fixes #500
1 parent 94de459 commit 896ee39

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# covr (development version)
22

3+
* `report()` now provides a more detailed error message if the `DT` and `htmltools` dependencies are not installed (#500).
4+
35
* Added `covr.record_tests` option. When `TRUE`, this enables the recording of
46
the trace of the tests being executed and adds an itemization of which tests
57
result in the execution of each trace. For more details see

R/report.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ report <- function(x = package_coverage(),
2121
# Paths need to be absolute for save_html to work properly
2222
file <- file.path(normalizePath(dirname(file), mustWork = TRUE), basename(file))
2323

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

2728
data <- to_report_data(x)
2829

0 commit comments

Comments
 (0)