Skip to content

Commit 5659da8

Browse files
authored
Use rlang's check_installed() (#1887)
1 parent f5c71bb commit 5659da8

File tree

4 files changed

+3
-15
lines changed

4 files changed

+3
-15
lines changed

R/reporter-junit.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ JunitReporter <- R6::R6Class("JunitReporter",
5656
},
5757

5858
start_reporter = function() {
59-
check_installed("xml2", "JunitReporter")
59+
check_installed("xml2", "to use JunitReporter")
6060

6161
self$timer <- private$proctime()
6262
self$doc <- xml2::xml_new_document()

R/snapshot-manage.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ snapshot_accept <- function(files = NULL, path = "tests/testthat") {
2929
#' @rdname snapshot_accept
3030
#' @export
3131
snapshot_review <- function(files = NULL, path = "tests/testthat") {
32-
check_installed("shiny", "snapshot_review()")
33-
check_installed("diffviewer", "snapshot_review()")
32+
check_installed(c("shiny", "diffviewer"), "to use snapshot_review()")
3433

3534
changed <- snapshot_meta(files, path)
3635
if (nrow(changed) == 0) {

R/test-compiled-code.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ expect_cpp_tests_pass <- function(package) {
3232
#' @export
3333
run_cpp_tests <- function(package) {
3434
skip_on_os("solaris")
35-
check_installed("xml2", "run_cpp_tests()")
35+
check_installed("xml2", "to run run_cpp_tests()")
3636

3737
run_testthat_tests <- get_routine(package, "run_testthat_tests")
3838

R/utils.R

-11
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,6 @@ rstudio_tickle <- function() {
8181
rstudioapi::executeCommand("refreshFiles")
8282
}
8383

84-
check_installed <- function(pkg, fun) {
85-
if (is_installed(pkg)) {
86-
return()
87-
}
88-
89-
abort(c(
90-
paste0("The ", pkg, " package must be installed in order to use `", fun, "`"),
91-
i = paste0("Do you need to run `install.packages('", pkg, "')`?")
92-
))
93-
}
94-
9584
first_upper <- function(x) {
9685
substr(x, 1, 1) <- toupper(substr(x, 1, 1))
9786
x

0 commit comments

Comments
 (0)