R/test-helpers.R

Defines functions defer local_devtools_package

local_devtools_package <- function(path, ..., env = parent.frame()) {
  pkgload::load_all(path, ..., quiet = TRUE)
  defer(pkgload::unload(pkgload::pkg_name(path)), scope = env)
}

defer <- function(expr, scope = parent.frame()) {
  expr <- enquo(expr)

  call <- expr(on.exit(rlang::eval_tidy(!!expr), add = TRUE))
  eval_bare(call, scope)

  invisible()
}

Try the downlit package in your browser

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

downlit documentation built on June 22, 2024, 9:17 a.m.