inst/testme/test-relaying,split.R

#' @tags relaying
#' @tags sequential

library(future)

options(future.debug = FALSE)

message("*** Relaying and split standard output and conditions ...")

message(" - default (implicit split = FALSE)")

plan(sequential)

relay <- recordRelay({
  f <- future({
    cat("O\n")
    message("M")
    1L
  })
})
message("  class: ", commaq(class(f)))
stopifnot(length(relay$stdout) == 0L)
stopifnot(length(relay$msgs) == 0L)
relay <- recordRelay(v <- value(f))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))


message(" - split = FALSE")

plan(sequential, split = FALSE)

relay <- recordRelay({
  f <- future({
    cat("O\n")
    message("M")
    1L
  })
})
message("  class: ", commaq(class(f)))
stopifnot(length(relay$stdout) == 0L)
stopifnot(length(relay$msgs) == 0L)
relay <- recordRelay(v <- value(f))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))


message(" - split = TRUE")

plan(sequential, split = TRUE)

relay <- recordRelay({
  f <- future({
    cat("O\n")
    message("M")
    1L
  })
})
message("  class: ", commaq(class(f)))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))
relay <- recordRelay(v <- value(f))
stopifnot(identical(relay$stdout, "O\n"))
stopifnot(identical(relay$msgs, "M\n"))


message("*** Relaying and split standard output and conditions ... DONE")

Try the future package in your browser

Any scripts or data that you put into this service are public.

future documentation built on April 12, 2025, 1:25 a.m.