Skip to content

Commit

Permalink
TESTS: Assert that packages **data.table** and **ff** are not affecte…
Browse files Browse the repository at this point in the history
…d when a future resets the R options on the worker when resolved (fix #20)
  • Loading branch information
HenrikBengtsson committed Nov 22, 2022
1 parent 9e0ddfa commit 11a2e9f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: future.tests
Title: Test Suite for 'Future API' Backends
Version: 0.3.0-9007
Version: 0.3.0-9008
Authors@R: c(
person("Henrik", "Bengtsson", role = c("aut", "cre", "cph"), email = "henrikb@braju.com"),
person(family = "The R Consortium", comment = "Project was awared an Infrastructure Steering Committee (ISC) grant in 2017", role = "fnd"))
Expand All @@ -14,7 +14,9 @@ Imports:
Suggests:
commonmark,
base64enc,
tools
tools,
data.table,
ff
VignetteBuilder: future.tests
License: LGPL (>= 2.1)
Encoding: UTF-8
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

* Assert that `rm(a)` in a future expression only removes a local
variable `a`, but never a global variable `a`.

* Assert that packages **data.table** and **ff** are not affected
when a future resets the R options on the worker when resolved.

## New Features

Expand Down
40 changes: 40 additions & 0 deletions inst/test-db/options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## https://github.com/HenrikBengtsson/future.tests/issues/20
make_test(title = "future() - preserve R options", tags = c("future", "options", "reset", "data.table"), {
if (requireNamespace("data.table")) {
data.table <- data.table::data.table
for (kk in 1:2) {
f <- future(data.table())
v <- value(f)
print(v)
stopifnot(
inherits(v, "data.frame"),
inherits(v, "data.table"),
nrow(v) == 0L,
ncol(v) == 0L
)
}
}
})



## https://github.com/HenrikBengtsson/future.tests/issues/20
make_test(title = "future() - preserve R options", tags = c("future", "options", "reset", "ff"), {
## AD HOC: Skip if not parallelizing on localhost
info <- Sys.info()
is_localhost <- value(future(identical(Sys.info(), info)))
if (is_localhost && requireNamespace("ff")) {
data <- ff::ff(1:12)
for (kk in 1:2) {
f <- future(data[4], packages = "ff")
v <- value(f)
print(v)
stopifnot(
is.integer(v),
length(v) == 1L,
identical(v, 4L)
)
}
}
})

0 comments on commit 11a2e9f

Please sign in to comment.