File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 11# testthat (development version)
22
3+ * ` skip_if_not_installed() ` produces a clearer message (@MichaelChirico , #1959 ).
34* ` with_mock() ` and ` local_mock() ` have been unconditionally deprecated as they will no longer work in future versions of R (#1999 ).
45* ` expect_condition() ` and friends now include the ` class ` of the expected condition in the failure mesage, if used (#1987 ).
56* ` LANGUAGE ` is now set to ` "C" ` in reprocucible environments (i.e.
Original file line number Diff line number Diff line change @@ -100,8 +100,14 @@ skip_if <- function(condition, message = NULL) {
100100# ' @param minimum_version Minimum required version for the package
101101# ' @rdname skip
102102skip_if_not_installed <- function (pkg , minimum_version = NULL ) {
103+ # most common case: it's not installed
104+ tryCatch(
105+ find.package(pkg ),
106+ error = function (e ) skip(paste0(" {" , pkg , " } is not installed" ))
107+ )
108+ # rarer: it's installed, but fails to load
103109 if (! requireNamespace(pkg , quietly = TRUE )) {
104- skip(paste0(pkg , " cannot be loaded" ))
110+ skip(paste0(" { " , pkg , " } cannot be loaded" ))
105111 }
106112
107113 if (! is.null(minimum_version )) {
Original file line number Diff line number Diff line change 2626
2727# skip_if_not_installed() works as expected
2828
29- Reason: doesntexist cannot be loaded
29+ Reason: { doesntexist} is not installed
3030
3131---
3232
You can’t perform that action at this time.
0 commit comments