Skip to content

Commit fae0f4b

Browse files
Use an option to decide if test dir is writeable
1 parent 1020852 commit fae0f4b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

R/testing.R

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,17 @@ test_collection <- function(test, sub_test = NULL,
4141

4242
out_names <- construct_out(in_names)
4343

44-
in_items <- file.path(path, in_names)
45-
out_items <- file.path(tempdir(), out_names)
46-
ref_items <- file.path(path, out_names)
47-
file.copy(ref_items, out_items, overwrite = TRUE, copy.mode = FALSE)
48-
out_trees <- file.path(tempdir(), construct_tree(in_names))
44+
if (getOption("styler.test_dir_unwritable")) {
45+
in_items <- file.path(path, in_names)
46+
out_items <- file.path(tempdir(), out_names)
47+
ref_items <- file.path(path, out_names)
48+
file.copy(ref_items, out_items, overwrite = TRUE, copy.mode = FALSE)
49+
out_trees <- file.path(tempdir(), construct_tree(in_names))
50+
} else {
51+
out_items <- file.path(path, out_names)
52+
in_items <- file.path(path, in_names)
53+
out_trees <- construct_tree(in_items)
54+
}
4955

5056
pwalk(list(in_items, out_items, in_names, out_names, out_trees),
5157
transform_and_check,
@@ -107,7 +113,8 @@ transform_and_check <- function(in_item, out_item,
107113
read_in <- xfun::read_utf8(in_item)
108114
if (write_tree) {
109115
create_tree(read_in) %>%
110-
write.table(out_tree, col.names = FALSE, row.names = FALSE, quote = FALSE, fileEncoding = "UTF-8")
116+
write.table(out_tree, col.names = FALSE, row.names = FALSE, quote = FALSE,
117+
fileEncoding = "UTF-8")
111118
}
112119
transformed_text <- read_in %>%
113120
transformer(...) %>%

R/zzz.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
styler.cache_name = styler_version,
77
styler.addins_style_transformer = "styler::tidyverse_style()",
88
styler.ignore_start = "# styler: off",
9-
styler.ignore_stop = "# styler: on"
9+
styler.ignore_stop = "# styler: on",
10+
styler.test_dir_unwritable = FALSE
1011
)
1112
toset <- !(names(op.styler) %in% names(op))
1213
if (any(toset)) options(op.styler[toset])

0 commit comments

Comments
 (0)