Skip to content

Commit a2b9d11

Browse files
move cache clearning into separate test file that is ran at the end.
1 parent 7c64a26 commit a2b9d11

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
test_that("styler tests did not use R.cache in user root", {
2+
skip_on_cran()
3+
skip_on_covr()
4+
skip_during_parallel()
5+
expect_true(
6+
length(list.files(R.cache::getCachePath("styler"), recursive = TRUE)) == 0L
7+
)
8+
})
9+
10+
test_that("clear Cache", {
11+
# if R CMD CHECK is running, R.cache root is set to a temp
12+
# directory by default.
13+
# https://github.com/HenrikBengtsson/R.cache/commit/c7ac171f15f035674346d5504049c38cf07c268f
14+
# Hence, this clean up won't clean up the user directory that Ripley is
15+
# concerned about, but only some temp directory.
16+
# On the other hand, it seems completely unclear how the user cache even gets
17+
# populated.
18+
# skip_during_parallel()
19+
cache_path <- R.cache::getCachePath("styler")
20+
R.cache::clearCache(cache_path, recursive = TRUE, prompt = FALSE)
21+
# rlang::abort(paste0('cache path:', cache_path))
22+
skip_on_cran()
23+
skip_on_covr()
24+
expect_true(
25+
length(list.dirs(R.cache::getCachePath("styler"))) == 1L
26+
)
27+
})

tests/testthat/test-zzz.R

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
test_that("styler tests did not use R.cache in user root", {
2-
skip_on_cran()
3-
skip_on_covr()
4-
expect_true(
5-
length(list.files(R.cache::getCachePath("styler"), recursive = TRUE)) == 0L
6-
)
7-
})
8-
9-
test_that("clear Cache", {
10-
R.cache::clearCache(R.cache::getCachePath("styler"), recursive = TRUE)
11-
skip_on_cran()
12-
skip_on_covr()
13-
expect_true(
14-
length(list.dirs(R.cache::getCachePath("styler"))) == 1L
15-
)
16-
})
17-
18-
191
test_that("can delete empty cache directory", {
202
skip_if(getRversion() < package_version("4.0.0"))
213
skip_on_cran()

0 commit comments

Comments
 (0)