Skip to content

Commit 111e7ef

Browse files
Merge branch 'communication' of github.com:michaelquinn32/styler into communication
2 parents fb87d37 + ed348a8 commit 111e7ef

File tree

11 files changed

+46
-24
lines changed

11 files changed

+46
-24
lines changed

NEWS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
- always strip trailing spaces and make cache insensitive to it (#626).
1818
- typos in documentation (#618, #614).
1919

20-
2120
# styler 1.3.2
2221

2322
Release upon request by the CRAN team.

R/io.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ transform_utf8_one <- function(path, fun, dry) {
3333
if (!identical) {
3434
if (dry == "fail") {
3535
rlang::abort(
36-
paste0("File `", path, "` would be modified by styler and `dry` = 'fail'."),
36+
paste0(
37+
"File `", path, "` would be modified by styler and argument dry",
38+
" is set to 'fail'."
39+
),
3740
class = "dryError"
3841
)
3942
} else if (dry == "on") {

R/testing.R

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

4242
out_names <- construct_out(in_names)
4343

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

4956
pwalk(list(in_items, out_items, in_names, out_names, out_trees),
5057
transform_and_check,
@@ -106,7 +113,9 @@ transform_and_check <- function(in_item, out_item,
106113
read_in <- xfun::read_utf8(in_item)
107114
if (write_tree) {
108115
create_tree(read_in) %>%
109-
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"
118+
)
110119
}
111120
transformed_text <- read_in %>%
112121
transformer(...) %>%

R/ui-styling.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ NULL
2222
#' @inheritParams prettify_pkg
2323
#' @section Warning:
2424
#' This function overwrites files (if styling results in a change of the
25-
#' code to be formatted). It is strongly suggested to only style files
26-
#' that are under version control or to create a backup copy.
25+
#' code to be formatted and `dry = "off"`). It is strongly suggested to only
26+
#' style files that are under version control or to create a backup copy.
2727
#'
2828
#' We suggest to first style with `scope < "tokens"` and inspect and commit
2929
#' changes, because these changes are guaranteed to leave the abstract syntax

R/zzz.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
styler.addins_style_transformer = "styler::tidyverse_style()",
88
styler.ignore_start = "# styler: off",
99
styler.ignore_stop = "# styler: on",
10-
styler.quiet = FALSE
10+
styler.quiet = FALSE,
11+
styler.test_dir_writable = TRUE
1112
)
1213
toset <- !(names(op.styler) %in% names(op))
1314
if (any(toset)) options(op.styler[toset])

man/style_dir.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_file.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/style_pkg.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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
)

0 commit comments

Comments
 (0)