tests/testthat/helper.R

local_package <- function() {
  dir <- tempfile()
  if (!dir.exists(dir)) {
    dir.create(dir)
  }
  
  withr::defer(unlink(dir, recursive = TRUE), parent.frame())

  writeLines("Package: testPkg", file.path(dir, "DESCRIPTION"))
  writeLines("useDynLib(testPkg, .registration = TRUE)", file.path(dir, "NAMESPACE"))
  desc::desc(dir)
}

pkg_path <- function(pkg) {
  dirname(pkg$.__enclos_env__$private$path)
}

Try the cpp11armadillo package in your browser

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

cpp11armadillo documentation built on June 8, 2025, 9:40 p.m.