R Under development (unstable) (2025-04-13 r88141 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. > library(future.tests) > library(future) > > lazy <- FALSE > global <- TRUE > stdout <- TRUE > value <- TRUE > recursive <- FALSE > > tests <- load_tests() > > test <- tests[[1]] > print(test) Test: - Title: 'future() - conditions' - Tags: 'future', 'conditions' - Reset workers: FALSE - Arguments: => Test combinations: 1 - Expression: 1: { 2: captureConditions <- function (...) 3: { 4: conditions <- list() 5: withCallingHandlers(..., condition = function(c) { 6: conditions[[length(conditions) + 1L]] <<- c 7: if (inherits(c, "message")) { 8: invokeRestart("muffleMessage") 9: } 10: else if (inherits(c, "warning")) { 11: invokeRestart("muffleWarning") 12: } 13: }) 14: conditions 15: } 16: truth <- captureConditions({ 17: message("hello") 18: warning("whoops") 19: message("world") 20: }) 21: f <- future({ 22: print(1:3) 23: message("hello") 24: warning("whoops") 25: message("world") 26: 42L 27: }) 28: r <- result(f) 29: str(r) 30: stopifnot(value(f) == 42L) 31: conditions <- r$conditions 32: stopifnot(is.list(conditions), length(conditions) == 3L) 33: conditions <- lapply(conditions, FUN = function(c) c$condition) 34: for (kk in seq_along(conditions)) { 35: stopifnot(identical(class(conditions[[kk]]), class(truth[[kk]])), 36: identical(conditions[[kk]]$message, truth[[kk]]$message)) 37: } 38: conditions <- captureConditions(value(f)) 39: stopifnot(is.list(conditions), length(conditions) == 3L) 40: for (kk in seq_along(conditions)) { 41: stopifnot(identical(class(conditions[[kk]]), class(truth[[kk]])), 42: identical(conditions[[kk]]$message, truth[[kk]]$message)) 43: } 44: } > > result <- run_test(test) > print(result) TestResult: - Test: - Title: 'future() - conditions' - Tags: 'future', 'conditions' - Reset workers: FALSE - Arguments: => Test combinations: 1 - Expression: 1: { 2: captureConditions <- function (...) 3: { 4: conditions <- list() 5: withCallingHandlers(..., condition = function(c) { 6: conditions[[length(conditions) + 1L]] <<- c 7: if (inherits(c, "message")) { 8: invokeRestart("muffleMessage") 9: } 10: else if (inherits(c, "warning")) { 11: invokeRestart("muffleWarning") 12: } 13: }) 14: conditions 15: } 16: truth <- captureConditions({ 17: message("hello") 18: warning("whoops") 19: message("world") 20: }) 21: f <- future({ 22: print(1:3) 23: message("hello") 24: warning("whoops") 25: message("world") 26: 42L 27: }) 28: r <- result(f) 29: str(r) 30: stopifnot(value(f) == 42L) 31: conditions <- r$conditions 32: stopifnot(is.list(conditions), length(conditions) == 3L) 33: conditions <- lapply(conditions, FUN = function(c) c$condition) 34: for (kk in seq_along(conditions)) { 35: stopifnot(identical(class(conditions[[kk]]), class(truth[[kk]])), 36: identical(conditions[[kk]]$message, truth[[kk]]$message)) 37: } 38: conditions <- captureConditions(value(f)) 39: stopifnot(is.list(conditions), length(conditions) == 3L) 40: for (kk in seq_along(conditions)) { 41: stopifnot(identical(class(conditions[[kk]]), class(truth[[kk]])), 42: identical(conditions[[kk]]$message, truth[[kk]]$message)) 43: } 44: } - Arguments tested: - Local evaluation: TRUE - Result: - Value: NULL - Visible: FALSE - Captured output: 1: 'List of 13' 2: ' $ value : int 42' 3: ' $ visible : logi TRUE' 4: ' $ stdout : chr "[1] 1 2 3\n"' 5: ' $ conditions :List of 3' 6: ' ..$ :List of 2' 7: ' .. ..$ condition:List of 2' 8: ' .. .. ..$ message: chr "hello\n"' 9: ' .. .. ..$ call : language message("hello")' 10: ' .. .. ..- attr(*, "class")= chr [1:3] "simpleMessage" "message" "condition"' 11: ' .. ..$ signaled : int 0' 12: ' ..$ :List of 2' 13: ' .. ..$ condition:List of 2' 14: ' .. .. ..$ message: chr "whoops"' 15: ' .. .. ..$ call : language eval(quote({ { ...' 16: ' .. .. ..- attr(*, "class")= chr [1:3] "simpleWarning" "warning" "condition"' 17: ' .. ..$ signaled : int 0' 18: ' ..$ :List of 2' 19: ' .. ..$ condition:List of 2' 20: ' .. .. ..$ message: chr "world\n"' 21: ' .. .. ..$ call : language message("world")' 22: ' .. .. ..- attr(*, "class")= chr [1:3] "simpleMessage" "message" "condition"' 23: ' .. ..$ signaled : int 0' 24: ' $ rng : logi FALSE' 25: ' $ misuseGlobalEnv : NULL' 26: ' $ misuseConnections:List of 3' 27: ' ..$ added : NULL' 28: ' ..$ removed : NULL' 29: ' ..$ replaced: NULL' 30: ' $ misuseDevices : NULL' 31: ' $ started : POSIXct[1:1], format: "2025-04-15 08:07:41"' 32: ' $ finished : POSIXct[1:1], format: "2025-04-15 08:07:41"' 33: ' $ session_uuid : chr "57e80aacb09687787e4266146d7ff960"' 34: ' ..- attr(*, "source")=List of 5' 35: ' .. ..$ host : Named chr "CRANWIN3"' 36: ' .. .. ..- attr(*, "names")= chr "COMPUTERNAME"' 37: ' .. ..$ info : Named chr [1:9] "Windows" "Server x64" "build 20348" "CRANWIN3" ...' 38: ' .. .. ..- attr(*, "names")= chr [1:9] "sysname" "release" "version" "nodename" ...' 39: ' .. ..$ pid : int 103384' 40: ' .. ..$ time : POSIXct[1:1], format: "2025-04-15 08:07:37"' 41: ' .. ..$ random: int 2147483647' 42: ' $ r_info :List of 4' 43: ' ..$ version :Classes 'R_system_version', 'package_version', 'numeric_version' hidden list of 1' 44: ' .. ..$ : int [1:3] 4 6 0' 45: ' ..$ os : chr "windows"' 46: ' ..$ os_name : chr "Windows"' 47: ' ..$ captures_utf8: logi TRUE' 48: ' $ version : chr "1.8"' 49: ' - attr(*, "class")= chr "FutureResult"' 50: '[1] 1 2 3' 51: '[1] 1 2 3' - Success: TRUE - Processing time: 0.223 secs > > proc.time() user system elapsed 4.18 0.17 4.34