R version 4.5.0 beta (2025-03-29 r88074 ucrt) -- "How About a Twenty-Six" 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 11' 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({ print(1:3) ...' 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: ' $ globalenv : NULL' 26: ' $ started : POSIXct[1:1], format: "2025-03-31 07:22:41"' 27: ' $ finished : POSIXct[1:1], format: "2025-03-31 07:22:41"' 28: ' $ session_uuid: chr "4759d6f8-9643-2e51-4fed-69ba6fabd0dd"' 29: ' ..- attr(*, "source")=List of 5' 30: ' .. ..$ host : Named chr "CRANWIN3"' 31: ' .. .. ..- attr(*, "names")= chr "COMPUTERNAME"' 32: ' .. ..$ info : Named chr [1:9] "Windows" "Server x64" "build 20348" "CRANWIN3" ...' 33: ' .. .. ..- attr(*, "names")= chr [1:9] "sysname" "release" "version" "nodename" ...' 34: ' .. ..$ pid : int 64092' 35: ' .. ..$ time : POSIXct[1:1], format: "2025-03-31 07:22:37"' 36: ' .. ..$ random: int 2147483647' 37: ' $ r_info :List of 4' 38: ' ..$ version :Classes 'R_system_version', 'package_version', 'numeric_version' hidden list of 1' 39: ' .. ..$ : int [1:3] 4 5 0' 40: ' ..$ os : chr "windows"' 41: ' ..$ os_name : chr "Windows"' 42: ' ..$ captures_utf8: logi TRUE' 43: ' $ version : chr "1.8"' 44: ' - attr(*, "class")= chr "FutureResult"' 45: '[1] 1 2 3' 46: '[1] 1 2 3' - Success: TRUE - Processing time: 0.215 secs > > proc.time() user system elapsed 4.09 0.20 4.28