Skip to content

Commit a748736

Browse files
Use find.package() for more precise skip note
1 parent 350e0a8 commit a748736

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

R/skip.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ skip_if <- function(condition, message = NULL) {
100100
#' @param minimum_version Minimum required version for the package
101101
#' @rdname skip
102102
skip_if_not_installed <- function(pkg, minimum_version = NULL) {
103+
# most common case: it's not installed
104+
res <- tryCatch(find.package(pkg), error = identity)
105+
if (inherits(res, "error")) {
106+
skip(paste0("{", pkg, "} is not installed"))
107+
}
108+
# rarer: it's installed, but fails to load
103109
if (!requireNamespace(pkg, quietly = TRUE)) {
104110
skip(paste0("{", pkg, "} cannot be loaded"))
105111
}

0 commit comments

Comments
 (0)