File: helper.R

package info (click to toggle)
r-cran-cpp11 0.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,428 kB
  • sloc: cpp: 9,732; sh: 14; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
local_package <- function() {
  dir <- tempfile()
  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)
}

get_funs <- function(path) {
  all_decorations <- decor::cpp_decorations(path, is_attribute = TRUE)
  get_registered_functions(all_decorations, "cpp11::register", quiet = TRUE)
}

get_package_name <- function(path) {
  desc::desc_get("Package", file = file.path(path, "DESCRIPTION"))
}

glue_str <- function(...) {
  glue::as_glue(unlist(list(...)))
}

read_file <- function(x) {
  readChar(x, file.size(x))
}

expect_error_free <- function(..., regexp = NA) {
  expect_error(..., regexp = regexp)
}