Skip to contents

To speed up development, pkgload::load_all() simulates installing a package. This simulation is usually sufficient, but there are edge cases which it cannot cover. Use this family of predicates to guard against these edge cases.

Usage

check_pkg_installed_but_not_via_loadall(x = character(1L))

assert_pkg_installed_but_not_via_loadall(
  x = character(1L),
  .var.name = checkmate::vname(x),
  add = NULL
)

test_pkg_installed_but_not_via_loadall(x = character(1L))

expect_pkg_installed_but_not_via_loadall(
  x = character(1L),
  info = NULL,
  label = vname(x)
)

skip_if_pkg_installed_but_not_via_loadall(...)

Arguments

x

Name of the package.

.var.name

[character(1)]
The custom name for x as passed to any assert* function. Defaults to a heuristic name lookup.

add

[AssertCollection]
Collection to store assertion messages. See AssertCollection.

info

[character(1)]
See expect_that

label

[character(1)]
See expect_that

...

[any]
List of calls to check functions.

Details

A frequent example of an edge case for pkgload::load_all() occurs when child processes are launched during development, such as in shinytest2. These child processes may not "know" that their parent used the load_all()d version of an in-development package, but may instead use whichever version was last installed. This can lead to inconsistent results and painful confusion.

Functions

  • check_pkg_installed_but_not_via_loadall(): returns TRUE or the error message as a string.

  • assert_pkg_installed_but_not_via_loadall(): returns x invisibly or errors out.

  • test_pkg_installed_but_not_via_loadall(): returns TRUE or FALSE

  • expect_pkg_installed_but_not_via_loadall(): returns an testthat::expectation()

  • skip_if_pkg_installed_but_not_via_loadall(): skips test if package is not installed.

See also

Other dependencies helper: is_installed2(), pkg_installed