Skip to content
Merged
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 NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ importFrom(utils,tail)
importFrom(withr,local_path)
importFrom(withr,with_dir)
importFrom(withr,with_envvar)
importFrom(withr,with_libpaths)
importFrom(xopen,xopen)
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Update pkgdown template and move url to https://rcmdcheck.r-lib.org.

* Fix usage of `libpath` argument (#195).

* `cran_check_results()` works again.

# rcmdcheck 1.4.0
Expand Down
7 changes: 3 additions & 4 deletions R/build.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @importFrom pkgbuild pkgbuild_process
#' @importFrom withr with_envvar
#' @importFrom withr with_libpaths

build_package <- function(path, tmpdir, build_args, libpath, quiet) {
path <- normalizePath(path)
Expand All @@ -15,9 +15,8 @@ build_package <- function(path, tmpdir, build_args, libpath, quiet) {
desc <- desc(path)
clean_doc <- as_flag(desc$get("Config/build/clean-inst-doc"), NULL)

with_envvar(
c("R_LIBS_USER" = paste(libpath, collapse = .Platform$path.sep)),
{
with_libpaths(
libpath, {
proc <- pkgbuild_process$new(
path,
tmpdir,
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/dependent_pkgs/pkg1/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Package: pkg1
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person("First", "Last", , "first.last@example.com", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
3 changes: 3 additions & 0 deletions tests/testthat/dependent_pkgs/pkg1/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated by roxygen2: do not edit by hand

export(foo1)
5 changes: 5 additions & 0 deletions tests/testthat/dependent_pkgs/pkg1/R/foo1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#' foo1 description
#'
#' foo1
#' @export
foo1 <- function() {1}
11 changes: 11 additions & 0 deletions tests/testthat/dependent_pkgs/pkg1/man/foo1.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/testthat/dependent_pkgs/pkg2/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Package: pkg2
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person("First", "Last", , "first.last@example.com", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
Imports:
pkg1
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Suggests:
knitr,
rmarkdown
VignetteBuilder: knitr
4 changes: 4 additions & 0 deletions tests/testthat/dependent_pkgs/pkg2/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(foo2)
import(pkg1)
6 changes: 6 additions & 0 deletions tests/testthat/dependent_pkgs/pkg2/R/foo2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' foo2 description
#'
#' foo2
#' @import pkg1
#' @export
foo2 <- function() {2}
11 changes: 11 additions & 0 deletions tests/testthat/dependent_pkgs/pkg2/man/foo2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions tests/testthat/dependent_pkgs/pkg2/vignettes/test.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "test"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{test}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
library(pkg2)
```
18 changes: 18 additions & 0 deletions tests/testthat/test-build.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,21 @@ test_that("inst/doc can be kept", {
pkg <- build_package(bad3, tempfile(), character(), .libPaths(), TRUE)
expect_true(file.exists(rubbish))
})

test_that("libpath argument is used in build_package", {
lib <- tempfile()
on.exit(unlink(lib, recursive = TRUE), add = TRUE)
dir.create(lib)

pkg1_source <- test_path("dependent_pkgs", "pkg1")
pkg1 <- pkgbuild::build(pkg1_source, quiet = TRUE)
on.exit(unlink(pkg1, recursive = TRUE), add = TRUE)
install.packages(pkg1, lib = lib, repos = NULL, type = "source", quiet = TRUE)

pkg2_source <- test_path("dependent_pkgs", "pkg2")
expect_error({
build_package(pkg2_source, tempfile(), character(), .libPaths(), TRUE)
})
pkg2 <- build_package(pkg2_source, tempfile(), character(), c(lib, .libPaths()), TRUE)
expect_true(file.exists(pkg2))
})
Loading