R Under development (unstable) (2025-06-05 r88281 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > source("incl/start.R") Loading required package: parallelly Loading required package: future > > plan(batchtools_local) > > ## CRAN processing times: > ## On Windows 32-bit, don't run these tests on batchtools > if (!fullTest && isWin32) plan(sequential) > > message("*** Globals - manually ...") *** Globals - manually ... > > message("*** Globals manually specified as named list ...") *** Globals manually specified as named list ... > > globals <- list( + a = 1, + b = 2, + sumtwo = function(x) x[1] + x[2] + ) > > ## Assign 'globals' globally > attach_locally(globals) > > ## Truth > v0 <- local({ + x <- 1:10 + sumtwo(a + b * x) + }) > > > message("*** Globals - automatic ...") *** Globals - automatic ... > > attach_locally(globals) > f <- future({ + x <- 1:10 + sumtwo(a + b * x) + }, globals = TRUE) [04:38:39.005] Launched future #1 > rm(list = names(globals)) > y <- value(f) > print(y) [1] 8 > stopifnot(all.equal(y, v0)) > > attach_locally(globals) > y %<-% { + x <- 1:10 + sumtwo(a + b * x) + } %globals% TRUE [04:38:40.474] Launched future #1 > rm(list = names(globals)) > print(y) [1] 8 > stopifnot(all.equal(y, v0)) > > ## No need to search for globals > y %<-% { 1 } %globals% FALSE [04:38:41.768] Launched future #1 > print(y) [1] 1 > stopifnot(identical(y, 1)) > > ## Exception - missing global > attach_locally(globals) > f <- future({ + x <- 1:10 + sumtwo(a + b * x) + }, globals = FALSE) [04:38:43.395] Launched future #1 > rm(list = names(globals)) > y <- tryCatch(value(f), error = identity) Warning in delete.BatchtoolsFuture(future) : Will not remove batchtools registry, because the status of the batchtools was 'error', 'defined', 'finished', 'started', 'submitted' and option 'future.delete' is FALSE or running in an interactive session: 'D:/temp/2025_06_06_04_35_16_24916/RtmpyuVycn/.future/20250606_043837-yuVycn/batchtools_921852061' > if (!inherits(f, c("SequentialFuture", "MulticoreFuture"))) { + stopifnot(inherits(y, "simpleError")) + } > > message("*** Globals - automatic ... DONE") *** Globals - automatic ... DONE > > > message("*** Globals manually specified as named list ...") *** Globals manually specified as named list ... > > ## Make sure globals do not exist > rm(list = names(globals)) Warning in rm(list = names(globals)) : object 'a' not found Warning in rm(list = names(globals)) : object 'b' not found Warning in rm(list = names(globals)) : object 'sumtwo' not found > > f <- future({ + x <- 1:10 + sumtwo(a + b * x) + }, globals = globals) [04:38:45.109] Launched future #1 > v <- value(f) > print(v) [1] 8 > stopifnot(all.equal(v, v0)) > > y %<-% { + x <- 1:10 + sumtwo(a + b * x) + } %globals% globals [04:38:46.863] Launched future #1 > print(y) [1] 8 > stopifnot(all.equal(y, v0)) > > message("*** Globals manually specified as named list ... DONE") *** Globals manually specified as named list ... DONE > > > message("*** Globals manually specified by their names ...") *** Globals manually specified by their names ... > > attach_locally(globals) > f <- future({ + x <- 1:10 + sumtwo(a + b * x) + }, globals = c("a", "b", "sumtwo")) [04:38:48.268] Launched future #1 > rm(list = names(globals)) > v <- value(f) > print(v) [1] 8 > stopifnot(all.equal(v, v0)) > > attach_locally(globals) > y %<-% { + x <- 1:10 + sumtwo(a + b * x) + } %globals% c("a", "b", "sumtwo") [04:38:50.235] Launched future #1 > rm(list = names(globals)) > print(y) [1] 8 > stopifnot(all.equal(y, v0)) > > message("*** Globals manually specified by their names ... DONE") *** Globals manually specified by their names ... DONE > > > message("*** Globals - manually ... DONE") *** Globals - manually ... DONE > > source("incl/end.R") > > proc.time() user system elapsed 2.23 0.62 14.42 Warning message: In delete.BatchtoolsFuture(f, onRunning = "skip", onMissing = "ignore", : Will not remove batchtools registry, because the status of the batchtools was 'error', 'defined', 'finished', 'started', 'submitted' and option 'future.delete' is FALSE or running in an interactive session: 'D:/temp/2025_06_06_04_35_16_24916/RtmpyuVycn/.future/20250606_043837-yuVycn/batchtools_921852061'