Skip to content

Commit c901718

Browse files
authored
These tests do more harm than good (#2542)
Closes #2477 As written, these tests (indirectly) call `remotes::update_packages("roxygen2")` which can cause package installation on any machine that runs the tests. And this installation is NOT scoped correctly, i.e. to a temporary library. I got fairly far into refactoring the tests, when I realized that fixing them introduced more complexity than was worth it. Passing arguments along isn't a tricky operation. devtools is better off without these tests.
1 parent 45354cf commit c901718

File tree

1 file changed

+0
-114
lines changed

1 file changed

+0
-114
lines changed

tests/testthat/test-install.R

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,3 @@
1-
library(mockery)
2-
3-
local({
4-
5-
pkg <- fs::path_real(local_package_create())
6-
7-
path2char <- function(x) {
8-
if (inherits(x, "fs_path")) {
9-
as.character(x)
10-
} else {
11-
x
12-
}
13-
}
14-
15-
expect_passes_args <- function(fn, stub, input_args = list(), expected_args) {
16-
mck <- mockery::mock(NULL)
17-
mockery::stub(fn, stub, mck)
18-
19-
capture.output(suppressMessages(do.call(fn, input_args)))
20-
21-
mockery::expect_called(mck, 1)
22-
mock_args <- mockery::mock_args(mck)[[1]]
23-
mock_args <- lapply(mock_args, path2char)
24-
expect_equal(mock_args, expected_args)
25-
}
26-
27-
custom_args <- list(
28-
dependencies = "dep",
29-
repos = "repo",
30-
type = "type",
31-
upgrade = "upgrade",
32-
quiet = "quiet",
33-
build = "build",
34-
build_opts = "build_opts"
35-
)
36-
37-
dep_defaults <- list(
38-
dependencies = NA,
39-
repos = getOption("repos"),
40-
type = getOption("pkgType"),
41-
upgrade = c("default", "ask", "always", "never"),
42-
quiet = FALSE,
43-
build = TRUE,
44-
build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes")
45-
)
46-
47-
dev_dep_defaults <- list(
48-
dependencies = TRUE,
49-
repos = getOption("repos"),
50-
type = getOption("pkgType"),
51-
upgrade = c("default", "ask", "always", "never"),
52-
quiet = FALSE,
53-
build = TRUE,
54-
build_opts = c("--no-resave-data", "--no-manual", " --no-build-vignettes")
55-
)
56-
57-
extra <- list(foo = "foo", bar = "bar")
58-
59-
test_that("install_deps passes default args to remotes::install_deps", {
60-
expect_passes_args(
61-
install_deps,
62-
"remotes::install_deps",
63-
list(pkg),
64-
c(pkg, dep_defaults)
65-
)
66-
})
67-
68-
test_that("install_deps passes custom args to remotes::install_deps", {
69-
expect_passes_args(
70-
install_deps,
71-
"remotes::install_deps",
72-
c(pkg, custom_args),
73-
c(pkg, custom_args)
74-
)
75-
})
76-
77-
test_that("install_deps passes ellipsis args to remotes::install_deps", {
78-
expect_passes_args(
79-
install_deps,
80-
"remotes::install_deps",
81-
c(pkg, extra),
82-
c(pkg, dep_defaults, extra)
83-
)
84-
})
85-
86-
test_that("install_dev_deps passes default args to remotes::install_deps", {
87-
expect_passes_args(
88-
install_dev_deps,
89-
"remotes::install_deps",
90-
list(pkg),
91-
c(pkg, dev_dep_defaults)
92-
)
93-
})
94-
95-
test_that("install_dev_deps passes custom args to remotes::install_deps", {
96-
expect_passes_args(
97-
install_dev_deps,
98-
"remotes::install_deps",
99-
c(pkg, custom_args),
100-
c(pkg, custom_args)
101-
)
102-
})
103-
104-
test_that("install_dev_deps passes ellipsis args to remotes::install_deps", {
105-
expect_passes_args(
106-
install_dev_deps,
107-
"remotes::install_deps",
108-
c(pkg, extra),
109-
c(pkg, dev_dep_defaults, extra)
110-
)
111-
})
112-
113-
})
114-
1151
test_that("vignettes built on install", {
1162
skip_on_cran()
1173

0 commit comments

Comments
 (0)