Skip to content

Commit 358e4a6

Browse files
Only update known_output if the test dir is writable
1 parent df9b1ed commit 358e4a6

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

tests/testthat/test-cache-with-r-cache.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ capture.output(test_that("cached expressions are displayed propperly", {
6464
cache_info <- cache_info("testthat", format = "tabular")
6565
expect_known_value(
6666
cache_info[, c("n", "size", "last_modified", "activated")],
67-
file = test_path("reference-objects/cache-info-1")
67+
file = test_path("reference-objects/cache-info-1"),
68+
update = getOption("styler.test_dir_writable", TRUE)
6869
)
6970

7071
activate_testthat_cache()
@@ -73,14 +74,18 @@ capture.output(test_that("cached expressions are displayed propperly", {
7374
cache_info$size <- round(cache_info$size, -2)
7475
expect_known_value(
7576
cache_info[, c("n", "size", "activated")],
76-
file = test_path("reference-objects/cache-info-2")
77+
file = test_path("reference-objects/cache-info-2"),
78+
update = getOption("styler.test_dir_writable", TRUE)
79+
7780
)
7881
style_text("a <-function() NULL")
7982
cache_info <- cache_info(format = "tabular")
8083
cache_info$size <- round(cache_info$size, -2)
8184
expect_known_value(
8285
cache_info[, c("n", "size", "activated")],
83-
file = test_path("reference-objects/cache-info-3")
86+
file = test_path("reference-objects/cache-info-3"),
87+
update = getOption("styler.test_dir_writable", TRUE)
88+
8489
)
8590
}))
8691

tests/testthat/test-public_api.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ test_that("messages (via cat()) of style_file are correct", {
163163
testthat_file(paste0(
164164
"public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-",
165165
encoding
166-
))
166+
)),
167+
update = getOption("styler.test_dir_writable", TRUE)
167168
)
168169

169170
# No message if scope > line_breaks and code does not change
@@ -175,7 +176,8 @@ test_that("messages (via cat()) of style_file are correct", {
175176
testthat_file(paste0(
176177
"public-api/xyzdir-dirty/clean-reference-with-scope-tokens-",
177178
encoding
178-
))
179+
)),
180+
update = getOption("styler.test_dir_writable", TRUE)
179181
)
180182

181183
# No message if scope <= line_breaks even if code is changed.
@@ -187,7 +189,8 @@ test_that("messages (via cat()) of style_file are correct", {
187189
testthat_file(paste0(
188190
"public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-",
189191
encoding
190-
))
192+
)),
193+
update = getOption("styler.test_dir_writable", TRUE)
191194
)
192195
}
193196
)

tests/testthat/test-utils.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ test_that("non-comment-helpers", {
1010
test_that("files with and without blank EOF line are read correctly", {
1111
expect_known_value(
1212
read_utf8(test_path("reference-objects/missing-blank-at-EOF.R")),
13-
test_path("reference-objects/return-read-utf8-missing-EOF")
13+
test_path("reference-objects/return-read-utf8-missing-EOF"),
14+
update = getOption("styler.test_dir_writable", TRUE)
1415
)
1516

1617
expect_known_value(
1718
read_utf8(test_path("reference-objects/non-missing-blank-at-EOF.R")),
18-
test_path("reference-objects/return-read-utf8-non-missing-EOF")
19+
test_path("reference-objects/return-read-utf8-non-missing-EOF"),
20+
update = getOption("styler.test_dir_writable", TRUE)
1921
)
2022
})

0 commit comments

Comments
 (0)