Check if a package is installed, but not via pkgload::load_all()
Source: R/installed.R
pkg_installed_but_not_via_loadall.RdTo 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 forxas passed to anyassert*function. Defaults to a heuristic name lookup.- add
[
AssertCollection]
Collection to store assertion messages. SeeAssertCollection.- info
[
character(1)]
Seeexpect_that- label
[
character(1)]
Seeexpect_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(): returnsTRUEor the error message as a string.assert_pkg_installed_but_not_via_loadall(): returnsxinvisibly or errors out.test_pkg_installed_but_not_via_loadall(): returnsTRUEorFALSEexpect_pkg_installed_but_not_via_loadall(): returns antestthat::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