Skip to content

Commit a3819b4

Browse files
committed
Add a test
1 parent fb3f2a0 commit a3819b4

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

tests/testthat/test-install.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ test_that("install reports stages", {
2121
)
2222
})
2323

24+
test_that("install() doesn't reinstall deps already in non-primary libpath", {
25+
skip_on_cran()
26+
27+
pkg <- local_package_copy(test_path("testInstallWithDeps"))
28+
withr::local_temp_libpaths()
29+
tmp_lib <- .libPaths()[1]
30+
31+
install(pkg, reload = FALSE, build = FALSE, quiet = TRUE)
32+
33+
installed <- setdiff(
34+
fs::path_file(fs::dir_ls(tmp_lib, type = "directory")),
35+
"_cache"
36+
)
37+
expect_equal(installed, "testInstallWithDeps")
38+
})
39+
2440
test_that("vignettes built on install", {
2541
skip_on_cran()
2642

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: testInstallWithDeps
2+
Title: Test Package With Dependencies
3+
Version: 0.1.0
4+
Authors@R: person("Test", "User", role = c("aut", "cre"), email = "test@example.com")
5+
Description: Minimal package used to test that devtools::install() does not
6+
reinstall dependencies that are already satisfied in a non-primary library.
7+
License: GPL-2
8+
Imports:
9+
cli
10+
Encoding: UTF-8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
importFrom(cli,cli_abort)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
hello <- function(x) {
2+
if (!is.character(x)) {
3+
cli::cli_abort("{.arg x} must be a character string.")
4+
}
5+
paste0("Hello, ", x, "!")
6+
}

0 commit comments

Comments
 (0)