| 1 |
expect_success <- function(x) expect_error(x, NA) |
| 2 |
|
| 3 |
# copied from fs package |
| 4 |
with_dir_tree <- function(files, code, base = tempfile()) { |
| 5 |
if (is.null(names(files))) { |
| 6 |
names(files) <- rep("", length(files)) |
| 7 |
} |
| 8 |
dirs <- dirname(names(files)) |
| 9 |
unnamed <- dirs == "" |
| 10 |
dirs[unnamed] <- files[unnamed] |
| 11 |
files[unnamed] <- list(NULL) |
| 12 |
|
| 13 |
fs::dir_create(fs::path(base, dirs)) |
| 14 |
old_wd <- setwd(base) |
| 15 |
on.exit({ |
| 16 |
unlink(base, recursive = TRUE, force = TRUE) |
| 17 |
setwd(old_wd) |
| 18 |
}) |
| 19 |
|
| 20 |
for (i in seq_along(files)) { |
| 21 |
if (!is.null(files[[i]])) { |
| 22 |
writeLines(files[[i]], con = names(files)[[i]]) |
| 23 |
} |
| 24 |
} |
| 25 |
force(code) |
| 26 |
} |