Skip to content

Commit c9a4f1a

Browse files
committed
Take more care around the order of the on.exit's
1 parent 400306a commit c9a4f1a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/testthat/test-write.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,18 @@ test_that("write_utf8() respects line ending", {
9696

9797
test_that("write_utf8() can operate outside of a project", {
9898
tmpdir <- file_temp()
99-
on.exit(dir_delete(tmpdir))
10099
dir_create(tmpdir)
100+
# doing this "by hand" vs. via withr because Windows appears to be unwilling
101+
# to delete current working directory
102+
oldwd <- setwd(tmpdir)
103+
on.exit({
104+
setwd(oldwd)
105+
dir_delete(tmpdir)
106+
})
101107

102-
withr::local_dir(tmpdir)
103108
local_project(NULL)
104109

105110
expect_false(proj_active())
106111
expect_error_free(write_utf8(path = "foo", letters[1:3]))
112+
107113
})

0 commit comments

Comments
 (0)