| 1 |
|
| 2 |
test_that("renv can be reloaded within the same session", { |
| 3 |
|
| 4 |
skip_on_cran() |
| 5 |
|
| 6 |
script <- renv_test_code({ |
| 7 |
|
| 8 |
# load renv tools |
| 9 |
renv:::summon() |
| 10 |
|
| 11 |
# set up temporary library path |
| 12 |
libdir <- tempfile("renv-library-") |
| 13 |
ensure_directory(libdir) |
| 14 |
.libPaths(libdir) |
| 15 |
|
| 16 |
# install CRAN version of renv |
| 17 |
options(warn = 2L) |
| 18 |
options(repos = c(CRAN = "https://cloud.R-project.org")) |
| 19 |
install("[email protected]") |
| 20 |
|
| 21 |
# unload and reload renv |
| 22 |
unloadNamespace("renv") |
| 23 |
loadNamespace("renv") |
| 24 |
|
| 25 |
# try writing out some data |
| 26 |
writeLines(paste(renv_package_version("renv"), renv_namespace_version("renv"))) |
| 27 |
|
| 28 |
}) |
| 29 |
|
| 30 |
output <- renv_system_exec( |
| 31 |
command = R(), |
| 32 |
args = c("--vanilla", "-s", "-f", renv_shell_path(script)), |
| 33 |
action = "reloading renv" |
| 34 |
) |
| 35 |
|
| 36 |
expect_equal(tail(output, n = 1L), "1.0.0 1.0.0") |
| 37 |
|
| 38 |
}) |