Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions R/not_loadalled.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' Skip if any of the packages come from `pkgload::load_all()`
#'
#' Loops over all packages in an object,
#' and skips if any of them are currently `pkgload::load_all()`d.
#' @inheritParams globals::globalsOf
#' @inheritDotParams globals::globalsOf
#' @keywords dependencies helper
#' @export
skip_if_any_pkgs_via_loadall <- function(expr, ...) {
pkgs_used <- globals::packagesOf(globals::globalsOf(expr = expr, ...))
purrr::walk(pkgs_used, elf::skip_if_pkg_installed_but_not_via_loadall)
}
16 changes: 16 additions & 0 deletions tests/testthat/test-not_loadalled.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
describe("skip_if_any_pkgs_via_loadall", {
it(
"skips expressions with non-existent packages",
expect_error(
skip_if_any_pkgs_via_loadall(

globals::packagesOf(
globals::globalsOf(
# str(rlang::parse_expr("base::abs(purrr::walk())"))

Check warning on line 9 in tests/testthat/test-not_loadalled.R

View workflow job for this annotation

GitHub Actions / Test, Check, Lint and Document Package (rlint)

file=tests/testthat/test-not_loadalled.R,line=9,col=15,[commented_code_linter] Commented code should be removed.
base::abs(purrr::walk(1, print))
)
)
)
)
)
})
Loading