| 1 |
|
| 2 |
test_that("renv can bootstrap itself if not installed", { |
| 3 |
|
| 4 |
skip_on_cran() |
| 5 |
skip_on_os("windows") |
| 6 |
|
| 7 |
# initialize bare project |
| 8 |
renv_tests_scope() |
| 9 |
init(bare = TRUE) |
| 10 |
|
| 11 |
# simulate bootstrap of renv from mock library |
| 12 |
renv_infrastructure_write_activate(version = "1.0.0") |
| 13 |
renv_scope_envvars( |
| 14 |
RENV_BOOTSTRAP_INSTALL_ONLY = "1", |
| 15 |
RENV_CONFIG_REPOS_OVERRIDE = getOption("repos") |
| 16 |
) |
| 17 |
|
| 18 |
# perform bootstrap |
| 19 |
args <- c("-s", "-e", shQuote("library(renv)")) |
| 20 |
stdout <- stderr <- if (interactive()) "" else FALSE |
| 21 |
status <- system2(R(), args, stdout = stdout, stderr = stderr) |
| 22 |
expect_equal(status, 0L) |
| 23 |
|
| 24 |
}) |
| 25 |
|
| 26 |
|
| 27 |
test_that("renv can bootstrap a dev version", { |
| 28 |
|
| 29 |
skip_slow() |
| 30 |
|
| 31 |
renv_tests_scope() |
| 32 |
init(bare = TRUE, restart = FALSE) |
| 33 |
|
| 34 |
version <- "1.0.0" |
| 35 |
attr(version, "sha") <- "5049cef8a" |
| 36 |
renv_infrastructure_write_activate(version = version) |
| 37 |
|
| 38 |
args <- c("-s", "-e", shQuote("requireNamespace(\"renv\")")) |
| 39 |
stdout <- stderr <- if (interactive()) "" else FALSE |
| 40 |
status <- system2(R(), args, stdout = stdout, stderr = stderr) |
| 41 |
expect_equal(status, 0L) |
| 42 |
|
| 43 |
# And should be fine if we run it again |
| 44 |
status <- system2(R(), args, stdout = stdout, stderr = stderr) |
| 45 |
expect_equal(status, 0L) |
| 46 |
}) |
| 47 |
|
| 48 |
test_that("activate_prompt behaves as expected", { |
| 49 |
renv_scope_options(renv.menu.choice = 2) |
| 50 |
expect_snapshot(val <- renv_activate_prompt_impl("snapshot")) |
| 51 |
expect_false(val) |
| 52 |
|
| 53 |
renv_tests_scope() |
| 54 |
renv_scope_options(renv.menu.choice = 1) |
| 55 |
expect_snapshot(val <- renv_activate_prompt_impl("snapshot")) |
| 56 |
expect_true(val) |
| 57 |
}) |