Skip to content

Commit

Permalink
Merge pull request #516 from jeanetteclark/b-515-testskips
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Jul 18, 2024
2 parents acbf331 + 14f1cfb commit 96828e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Imports:
rlang
Suggests:
callr,
cli,
DBItest (>= 1.8.0),
gert,
gh,
Expand Down
10 changes: 6 additions & 4 deletions R/import-standalone-check_suggested.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rlang::local_options(test_package_name = "RSQLite", .frame = teardown_env())

0 comments on commit 96828e3

Please sign in to comment.