| 1 |
|
| 2 |
test_that("clean removes stale lockfiles", { |
| 3 |
|
| 4 |
renv_tests_scope("bread") |
| 5 |
|
| 6 |
init() |
| 7 |
library <- renv_paths_library() |
| 8 |
|
| 9 |
# old temporary directory |
| 10 |
tmpdir <- tempfile(tmpdir = library) |
| 11 |
ensure_directory(tmpdir) |
| 12 |
|
| 13 |
# stale lockfile |
| 14 |
lockpath <- file.path(library, "00LOCK-package") |
| 15 |
ensure_directory(lockpath) |
| 16 |
Sys.setFileTime(lockpath, Sys.time() - 36000) |
| 17 |
|
| 18 |
# installed but unused package |
| 19 |
suppressWarnings(install("toast")) |
| 20 |
|
| 21 |
# clean up the project |
| 22 |
actions <- c("package.locks", "library.tempdirs", "unused.packages") |
| 23 |
clean(actions = actions) |
| 24 |
|
| 25 |
# check the project has been cleaned |
| 26 |
expect_false(file.exists(tmpdir)) |
| 27 |
expect_false(file.exists(lockpath)) |
| 28 |
expect_false(file.exists(file.path(library, "toast"))) |
| 29 |
|
| 30 |
}) |