diff --git a/DESCRIPTION b/DESCRIPTION index 1d6f0c5b7..ea58b2351 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,6 +42,7 @@ Imports: rlang Suggests: callr, + cli, DBItest (>= 1.8.0), gert, gh, diff --git a/R/import-standalone-check_suggested.R b/R/import-standalone-check_suggested.R index e9ad8efa5..5dc8985ae 100644 --- a/R/import-standalone-check_suggested.R +++ b/R/import-standalone-check_suggested.R @@ -6,9 +6,9 @@ # --- # repo: cynkra/dm # file: standalone-check_suggested.R -# last-updated: 2023-02-23 +# last-updated: 2024-07-17 # license: https://unlicense.org -# imports: rlang, cli, glue +# imports: rlang, cli # --- # # This file provides a wrapper around `rlang::check_installed()` that skips tests @@ -20,6 +20,8 @@ # # 2023-10-19: # * Initial +# 2024-07-17: +# * Skip tests only when the test env is for this package, and correctly format the message # nocov start @@ -58,9 +60,9 @@ check_suggested <- function(packages, top_level_fun, use = TRUE) { # Skip if some packages are not installed when testing # And say which package was not installed. - if (identical(Sys.getenv("TESTTHAT"), "true")) { + if (identical(Sys.getenv("TESTTHAT"), "true") && identical(getOption("test_package_name"), environmentName(topenv()))) { pkgs_not_installed <- packages[!installed] - message <- "{.fn {top_level_fun}} needs the {.pkg {.val {pkgs_not_installed}}} package{?s}." + message <- cli::cli_li("{.fn {top_level_fun}} needs the {.pkg {.val {pkgs_not_installed}}} package{?s}.") testthat::skip(message) } diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 000000000..891dcedd4 --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1 @@ +rlang::local_options(test_package_name = "RSQLite", .frame = teardown_env())