Skip to content
Closed
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
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
^\.claude$
^CRAN-SUBMISSION$
^doc$
^\.ai$
19 changes: 18 additions & 1 deletion R/compile-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,26 @@ compile_package <- function(path = ".") {
# TODO: need to unset various R_* env vars, or just
# take a dep on callr
# TODO: prompt to install pkgload if not available?
quickr_dev_path <- if (
requireNamespace("pkgload", quietly = TRUE) &&
pkgload::is_dev_package("quickr")
) {
getNamespaceInfo(asNamespace("quickr"), "path")
}
load_quickr <- if (
is_string(quickr_dev_path) &&
nzchar(quickr_dev_path) &&
file.exists(file.path(quickr_dev_path, "DESCRIPTION"))
) {
sprintf("pkgload::load_all(%s, quiet = TRUE)", shQuote(quickr_dev_path))
}
r_code <- paste(
c(load_quickr, "pkgload::load_all(quiet = TRUE)"),
collapse = "; "
)
out <- suppressWarnings(system2(
file.path(R.home("bin"), "R"),
c("-q", "-e", shQuote("pkgload::load_all(quiet = TRUE)")),
c("-q", "-e", shQuote(r_code)),
stdout = TRUE,
stderr = TRUE
))
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-compile-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ run_r <- function(code) {
out
}

quickr_dev_path <- getNamespaceInfo(asNamespace("quickr"), "path")

test_that("compile_package errors when path is not an R package", {
temp <- withr::local_tempdir()
expect_error(
Expand Down Expand Up @@ -149,6 +151,7 @@ test_that("pkgload::load_all writes outputs and resolves anonymous quick() names
code <- paste(
sprintf("setwd(%s)", shQuote(pkgpath)),
"suppressPackageStartupMessages(library(pkgload))",
sprintf("pkgload::load_all(%s, quiet = TRUE)", shQuote(quickr_dev_path)),
"pkgload::load_all('.', quiet = TRUE)",
sep = "; "
)
Expand All @@ -170,6 +173,7 @@ test_that("pkgload::load_all messages when NAMESPACE lacks useDynLib", {
code <- paste(
sprintf("setwd(%s)", shQuote(pkgpath)),
"suppressPackageStartupMessages(library(pkgload))",
sprintf("pkgload::load_all(%s, quiet = TRUE)", shQuote(quickr_dev_path)),
"pkgload::load_all('.', quiet = TRUE)",
sep = "; "
)
Expand Down
Loading