Skip to content

Commit ab0d03b

Browse files
CLEANUP: Don't have R CMD check leave files behind [#30]
1 parent ea9985f commit ab0d03b

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

NEWS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: future.batchtools
22
==========================
33

4-
Version: 0.8.0-9000 [2019-05-05]
4+
Version: 0.8.0-9000 [2019-06-07]
55

66
* ...
77

R/future_cache_path.R

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
#' @importFrom utils file_test sessionInfo
22
future_cache_path <- local({
3-
## The path used for this session
4-
path <- NULL
3+
## The subfolder used for this session
4+
dir <- NULL
55

66
function(root_path = Sys.getenv("R_FUTURE_CACHE_PATH", ".future"), absolute = TRUE, create = TRUE) {
7-
if (is.null(path)) {
7+
if (is.null(dir)) {
88
id <- basename(tempdir())
99
id <- gsub("Rtmp", "", id, fixed = TRUE)
1010
timestamp <- format(Sys.time(), format = "%Y%m%d_%H%M%S")
11-
dir <- sprintf("%s-%s", timestamp, id)
12-
path_tmp <- file.path(root_path, dir)
13-
if (create && !file_test("-d", path_tmp)) {
14-
dir.create(path_tmp, recursive = TRUE)
15-
pathname_tmp <- file.path(path_tmp, "sessioninfo.txt")
16-
writeLines(capture_output(print(sessionInfo())), con = pathname_tmp)
17-
}
18-
path <<- path_tmp
11+
dir <<- sprintf("%s-%s", timestamp, id)
1912
}
13+
14+
path <- file.path(root_path, dir)
15+
if (create && !file_test("-d", path)) {
16+
dir.create(path, recursive = TRUE)
17+
pathname <- file.path(path, "sessioninfo.txt")
18+
writeLines(capture_output(print(sessionInfo())), con = pathname)
19+
}
20+
2021
if (absolute) path <- normalizePath(path, mustWork = FALSE)
2122

2223
path

R/zzz.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.onLoad <- function(libname, pkgname) {
2+
inRCmdCheck <- import_future("inRCmdCheck")
3+
if (inRCmdCheck()) {
4+
Sys.setenv("R_FUTURE_CACHE_PATH" = file.path(tempdir(), ".future"))
5+
}
6+
}
7+
18
#' @importFrom utils file_test
29
.onUnload <- function(libpath) {
310
## (a) Force finalizer of Future objects to run such

tests/incl/start,load-only.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ oplan <- future::plan()
1212
## Use local batchtools futures by default
1313
future::plan(future.batchtools::batchtools_local)
1414

15+
Sys.setenv("R_FUTURE_CACHE_PATH" = file.path(tempdir(), ".future"))
16+
1517
fullTest <- (Sys.getenv("_R_CHECK_FULL_") != "")
1618

1719
isWin32 <- (.Platform$OS.type == "windows" && .Platform$r_arch == "i386")

0 commit comments

Comments
 (0)