Skip to content

Commit

Permalink
tell r where to find fs functions so that tests pass locally
Browse files Browse the repository at this point in the history
  • Loading branch information
crew102 committed Oct 2, 2018
1 parent 5c79f2f commit e20ecba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions R/filepaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
make_filebase <- function(outfile = NULL, infile = NULL) {
if (is.null(outfile)) {
## work inside a new directory, within session temp directory
target_dir <- path_real(dir_create(file_temp("reprex")))
target_dir <- fs::path_real(fs::dir_create(fs::file_temp("reprex")))
## example: /private/var/.../.../.../reprex97d77de2835c/reprex
return(path(target_dir, "reprex"))
}
Expand All @@ -14,7 +14,7 @@ make_filebase <- function(outfile = NULL, infile = NULL) {
if (is.null(infile)) {
## outfile = NA, infile = NULL --> reprex in working directory
## example: reprexbfa165580676
path_file(file_temp("reprex"))
fs::path_file(fs::file_temp("reprex"))
} else {
## outfile = NA, infile = "sthg" --> follow infile's lead
## example: basename_of_infile
Expand Down Expand Up @@ -44,14 +44,14 @@ force_tempdir <- function(path) {
if (is_in_tempdir(path)) {
path
} else {
file_copy(path, path_temp(path_file(path)), overwrite = TRUE)
fs::file_copy(path, fs::path_temp(fs::path_file(path)), overwrite = TRUE)
}
}

is_in_tempdir <- function(path) {
identical(
path_real(path_temp()),
path_common(path_real(c(path, path_temp())))
fs::path_real(fs::path_temp()),
fs::path_common(fs::path_real(c(path, fs::path_temp())))
)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ expect_error_free <- function(...) {

## set wd to session temp dir, execute testing code, restore previous wd
temporarily <- function(env = parent.frame()) {
withr::local_dir(path_temp(), .local_envir = env)
withr::local_dir(fs::path_temp(), .local_envir = env)
}

## call during interactive test development to fake being "in tests" and thereby
Expand Down

0 comments on commit e20ecba

Please sign in to comment.