tests/testthat/testUserLoadHook/R/testUserLoadHook.R

.onLoad <- function(...) {
  stopifnot(!environmentIsLocked(asNamespace("testUserLoadHook")))

  setHook(
    packageEvent("testUserLoadHookUpstream", "onLoad"),
    function(...) {
      stopifnot(environmentIsLocked(asNamespace("testUserLoadHookUpstream")))

      # The package exports are populated when user onLoad hooks are run
      stopifnot(is.null(testUserLoadHookUpstream::foo()))

      rlang::signal("", "hook_was_run")
    }
  )
}

Try the pkgload package in your browser

Any scripts or data that you put into this service are public.

pkgload documentation built on June 28, 2024, 5:07 p.m.