Skip to content

Commit 04eb162

Browse files
committed
censor machine dependent paths in snapshots
1 parent ae57ec7 commit 04eb162

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/testthat/test-ggsave.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ test_that("ggsave can create directories", {
1616

1717
p <- ggplot(mpg, aes(displ, hwy)) + geom_point()
1818

19-
expect_snapshot(ggsave(path, p), error = TRUE)
19+
expect_snapshot(
20+
ggsave(path, p), error = TRUE,
21+
transform = function(x) gsub("directory '.*'\\.$", "directory 'PATH'", x)
22+
)
2023
expect_false(dir.exists(dirname(path)))
2124

2225
# 2 messages: 1 for saving and 1 informing about directory creation
@@ -88,7 +91,10 @@ test_that("ggsave warns about empty or multiple filenames", {
8891

8992
test_that("ggsave fails informatively for no-extension filenames", {
9093
plot <- ggplot(mtcars, aes(disp, mpg)) + geom_point()
91-
expect_snapshot(ggsave(tempfile(), plot), error = TRUE)
94+
expect_snapshot(
95+
ggsave(tempfile(), plot), error = TRUE,
96+
transform = function(x) gsub("to .*\\.$", "to PATH", x)
97+
)
9298
})
9399

94100
# plot_dim ---------------------------------------------------------------

0 commit comments

Comments
 (0)