Running ‘fold.R’ [7s/8s]
  Running ‘future_apply.R’ [4s/7s]
  Running ‘future_eapply.R’ [2s/5s]
  Running ‘future_lapply,RNG.R’ [2s/5s]
  Running ‘future_lapply,globals.R’ [3s/9s]
  Running ‘future_lapply.R’ [13s/18s]
  Running ‘future_mapply,globals.R’ [3s/7s]
  Running ‘future_mapply.R’ [4s/9s]
  Running ‘future_replicate.R’ [3s/7s]
  Running ‘future_sapply.R’ [21s/33s]
  Running ‘future_tapply.R’ [1s/1s]
  Running ‘future_vapply.R’ [7s/15s]
  Running ‘globals,tricky_recursive.R’ [2s/5s]
  Running ‘rng.R’ [1s/1s]
  Running ‘stdout.R’ [2s/22s]
  Running ‘utils.R’ [1s/1s]
Running the tests in ‘tests/future_lapply,RNG.R’ failed.
Complete output:
  > source("incl/start.R")
  Loading required package: future
  plan(): Setting new future strategy stack:
  List of future strategies:
  1. sequential:
     - args: function (expr, envir = parent.frame(), substitute = TRUE, lazy = FALSE, seed = NULL, globals = TRUE, local = TRUE, earlySignal = FALSE, label = NULL, ...)
     - tweaked: FALSE
     - call: future::plan("sequential")
  
  plan(): nbrOfWorkers() = 1
  > 
  > message("*** future_lapply() and RNGs ...")
  *** future_lapply() and RNGs ...
  > 
  > options(future.debug = FALSE)
  > 
  > message("* future_lapply(x, ..., future.seed = <invalid>) ...")
  * future_lapply(x, ..., future.seed = <invalid>) ...
  > 
  > res <- tryCatch({
  +   y <- future_lapply(1:3, FUN = identity, future.seed = as.list(1:2))
  + }, error = identity)
  > print(res)
  <simpleError in make_rng_seeds(nX, seed = future.seed, debug = debug): Argument 'seed' is a list, which specifies the sequence of seeds to be used for each element iterated over, but length(seed) != number of elements: 2 != 3>
  > stopifnot(inherits(res, "simpleError"))
  > 
  > res <- tryCatch({
  +   y <- future_lapply(1:3, FUN = identity, future.seed = list(1, 2, 3:4))
  + }, error = identity)
  > print(res)
  <simpleError in make_rng_seeds(nX, seed = future.seed, debug = debug): The elements of the list specified in argument 'seed' are not all of the same lengths (did you really pass RNG seeds?): 1, 2>
  > stopifnot(inherits(res, "simpleError"))
  > 
  > res <- tryCatch({
  +   y <- future_lapply(1:3, FUN = identity, future.seed = as.list(1:3))
  + }, error = identity)
  > print(res)
  <simpleError in make_rng_seeds(nX, seed = future.seed, debug = debug): Argument 'seed' is invalid. Pre-generated random seeds must be valid .Random.seed seeds, which means they should be all integers and consists of two or more elements, not just one.>
  > stopifnot(inherits(res, "simpleError"))
  > 
  > seeds <- lapply(1:3, FUN = as_lecyer_cmrg_seed)
  > res <- tryCatch({
  +   y <- future_lapply(1:3, FUN = identity, future.seed = lapply(seeds, FUN = as.numeric))
  + }, error = identity)
  > print(res)
  <simpleError in make_rng_seeds(nX, seed = future.seed, debug = debug): The elements of the list specified in argument 'seed' are not all integers (did you really pass RNG seeds?): double>
  > stopifnot(inherits(res, "simpleError"))
  > 
  > seeds[[1]][1] <- seeds[[1]][1] + 1L
  > res <- tryCatch({
  +   y <- future_lapply(1:3, FUN = identity, future.seed = seeds)
  + }, error = identity)
  > print(res)
  <simpleError in make_rng_seeds(nX, seed = future.seed, debug = debug): The list in argument 'seed' does not seem to hold elements that are valid .Random.seed values:  int [1:7] 10408 1280795612 -169270483 -442010614 -603558397 -222347416 1489374793>
  > stopifnot(inherits(res, "simpleError"))
  > 
  > message("* future_lapply(x, ..., future.seed = <invalid>) ... DONE")
  * future_lapply(x, ..., future.seed = <invalid>) ... DONE
  > 
  > 
  > ## Iterate of the same set in all tests
  > x <- 1:5
  > 
  > message("* future_lapply(x, ..., future.seed = FALSE) ...")
  * future_lapply(x, ..., future.seed = FALSE) ...
  > 
  > y0 <- y0_nested <- seed00 <- NULL
  > for (cores in 1:availCores) {
  +   message(sprintf("  - Testing with %d cores ...", cores))
  +   options(mc.cores = cores)
  +   
  +   for (strategy in supportedStrategies(cores)) {
  +     message(sprintf("* plan('%s') ...", strategy))
  +     plan(strategy)
  +   
  +     set.seed(0xBEEF)
  +     seed0 <- get_random_seed()
  +     y <- future_lapply(x, FUN = function(i) i, future.seed = FALSE)
  +     y <- unlist(y)
  +     seed <- get_random_seed()
  +     if (is.null(y0)) {
  +       y0 <- y
  +       seed00 <- seed
  +     }
  +     str(list(y = y))
  +     stopifnot(identical(seed, seed0), identical(seed, seed00))
  +     ## NOTE: We cannot guarantee the same random numbers, because
  +     ## future.seed = FALSE.
  +     
  +     message(sprintf("* plan('%s') ... DONE", strategy))
  +   }  ## for (strategy ...)
  +   message(sprintf("  - Testing with %d cores ... DONE", cores))
  + } ## for (core ...)
    - Testing with 1 cores ...
  * plan('sequential') ...
  List of 1
   $ y: int [1:5] 1 2 3 4 5
  * plan('sequential') ... DONE
  * plan('multicore') ...
  List of 1
   $ y: int [1:5] 1 2 3 4 5
  * plan('multicore') ... DONE
  * plan('multisession') ...
  List of 1
   $ y: int [1:5] 1 2 3 4 5
  * plan('multisession') ... DONE
    - Testing with 1 cores ... DONE
    - Testing with 2 cores ...
  * plan('multicore') ...
  List of 1
   $ y: int [1:5] 1 2 3 4 5
  * plan('multicore') ... DONE
  * plan('multisession') ...
  List of 1
   $ y: int [1:5] 1 2 3 4 5
  * plan('multisession') ... DONE
    - Testing with 2 cores ... DONE
  > 
  > message("* future_lapply(x, ..., future.seed = FALSE) ... DONE")
  * future_lapply(x, ..., future.seed = FALSE) ... DONE
  > 
  > 
  > seed_sets <- list(
  +   A = TRUE,
  +   B = NA,
  +   C = 42L,
  +   D = as_lecyer_cmrg_seed(42L),
  +   E = list(),
  +   F = vector("list", length = length(x)),
  +   G = NULL
  + )
  > 
  > ## Generate sequence of seeds of the current RNGkind()
  > ## NOTE: This is NOT a good way to generate random seeds!!!
  > seeds <- lapply(seq_along(x), FUN = function(i) {
  +   set.seed(i)
  +   globalenv()$.Random.seed
  + })
  > seed_sets$E <- seeds
  > 
  > ## Generate sequence of L'Ecyer CMRG seeds
  > seeds <- seed_sets$F
  > seeds[[1]] <- seed_sets$D
  > for (kk in 2:length(x)) seeds[[kk]] <- parallel::nextRNGStream(seeds[[kk - 1]])
  > seed_sets$F <- seeds
  > seed_sets$G <- seed_sets$A
  > 
  > rm(list = "seeds")
  > 
  > for (name in names(seed_sets)) {
  +   future.seed <- seed_sets[[name]]
  + 
  +   if (is.list(future.seed)) {
  +     label <- sprintf("<list of %d seeds each being a %d-int seed>",
  +                      length(future.seed), length(future.seed[[1]]))
  +   } else {
  +     label <- hpaste(future.seed)
  +   }
  +   message(sprintf("* future_lapply(x, ..., future.seed = %s) ...", label))
  +   
  +   set.seed(0xBEEF)
  +   y0 <- seed00 <- NULL
  + 
  +   for (cores in 1:availCores) {
  +     message(sprintf("  - Testing with %d cores ...", cores))
  +     options(mc.cores = cores)
  +   
  +     for (strategy in supportedStrategies(cores)) {
  +       message(sprintf("* plan('%s') ...", strategy))
  +       plan(strategy)
  +       
  +       set.seed(0xBEEF)
  +       seed0 <- get_random_seed()
  +       y <- future_lapply(x, FUN = function(i) {
  +         rnorm(1L)
  +       }, future.seed = future.seed)
  +       y <- unlist(y)
  +       seed <- get_random_seed()
  +       if (is.null(y0)) {
  +         y0 <- y
  +         seed00 <- seed
  +       }
  +       str(list(y = y))
  +       stopifnot(!identical(seed, seed0), identical(seed, seed00),
  +                 identical(y, y0))
  +   
  +       ## RNG-based results should also be identical regardless of
  +       ## load-balance scheduling.
  +       for (scheduling in list(FALSE, TRUE, 0, 0.5, 2.0, Inf)) {
  +         set.seed(0xBEEF)
  +         seed0 <- get_random_seed()
  +         y <- future_lapply(x, FUN = function(i) {
  +           rnorm(1L)
  +         }, future.seed = future.seed, future.scheduling = scheduling)
  +         seed <- get_random_seed()
  +         y <- unlist(y)
  +         str(list(y = y))
  +         stopifnot(!identical(seed, seed0), identical(seed, seed00),
  +                   identical(y, y0))
  +       }
  +   
  +       ## Nested future_lapply():s
  +       for (scheduling in list(FALSE, TRUE)) {
  +         y <- future_lapply(x, FUN = function(i) {
  +           .seed <- globalenv()$.Random.seed
  +           
  +           z <- future_lapply(1:3, FUN = function(j) {
  +             list(j = j, seed = globalenv()$.Random.seed)
  +           }, future.seed = .seed)
  +     
  +           ## Assert that all future seeds are unique
  +           seeds <- lapply(z, FUN = function(x) x$seed)
  +           for (kk in 2:length(seeds)) stopifnot(!all(seeds[[kk]] == seeds[[1]]))
  +           
  +           list(i = i, seed = .seed, sample = rnorm(1L), z = z)
  +         }, future.seed = 42L, future.scheduling = scheduling)
  +   
  +         if (is.null(y0_nested)) y0_nested <- y
  +         str(list(y = y))
  +     
  +         ## Assert that all future seeds (also nested ones) are unique
  +         seeds <- Reduce(c, lapply(y, FUN = function(x) {
  +           c(list(seed = x$seed), lapply(x$z, FUN = function(x) x$seed))
  +         }))
  +         for (kk in 2:length(seeds)) stopifnot(!all(seeds[[kk]] == seeds[[1]]))
  +         
  +         stopifnot(identical(y, y0_nested))
  +       }
  +       
  +       message(sprintf("* plan('%s') ... DONE", strategy))
  +     } ## for (strategy ...)
  +     message(sprintf("  - Testing with %d cores ... DONE", cores))
  +   } ## for (cores ...)
  +   
  +   message(sprintf("* future_lapply(x, ..., future.seed = %s) ... DONE", label))
  + 
  + } ## for (name ...)
  * future_lapply(x, ..., future.seed = TRUE) ...
    - Testing with 1 cores ...
  * plan('sequential') ...
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  List of 1
   $ y: num [1:5] -1.316 -1.5 2.787 -0.193 -1.704
  Error in as_lecyer_cmrg_seed(seed) : 
    Argument 'seed' must be L'Ecuyer-CMRG RNG seed as returned by parallel::nextRNGStream() or an single integer:  int [1:7] 10407 -1871565002 1968597656 -505666782 1055078269 658163990 1090264187
  Calls: future_lapply ... values.list -> value -> value.Future -> resignalConditions
  Execution halted
Running the tests in ‘tests/rng.R’ failed.
Complete output:
  > source("incl/start,load-only.R")
  Detected 'R CMD check':
   - adjusting defaults to be a good citizen
  Future-specific environment variables:
  - R_FUTURE_MAKENODEPSOCK_CONNECTTIMEOUT='120'
  - R_FUTURE_MAKENODEPSOCK_RSCRIPT_LABEL='TRUE'
  - R_FUTURE_MAKENODEPSOCK_SESSIONINFO_PKGS='TRUE'
  - R_FUTURE_MAKENODEPSOCK_TIMEOUT='120'
  - R_FUTURE_WAIT_INTERVAL='0.01'
  R process uuid: a326efd3-8f69-c145-77ff-586b3c88f3ce
  Setting plan('default')
  plan(): Setting new future strategy stack:
  List of future strategies:
  1. sequential:
     - args: function (expr, envir = parent.frame(), substitute = TRUE, lazy = FALSE, seed = NULL, globals = TRUE, local = TRUE, earlySignal = FALSE, label = NULL, ...)
     - tweaked: FALSE
     - call: NULL
  
  plan(): nbrOfWorkers() = 1
  plan(): Setting new future strategy stack:
  List of future strategies:
  1. sequential:
     - args: function (expr, envir = parent.frame(), substitute = TRUE, lazy = FALSE, seed = NULL, globals = TRUE, local = TRUE, earlySignal = FALSE, label = NULL, ...)
     - tweaked: FALSE
     - call: future::plan("sequential")
  
  plan(): nbrOfWorkers() = 1
  > 
  > message("*** RNG ...")
  *** RNG ...
  > 
  > set_random_seed(seed = NULL)
  > seed <- get_random_seed()
  > stopifnot(is.null(seed))
  > 
  > set_random_seed(seed = 42L)
  > seed <- get_random_seed()
  > stopifnot(identical(seed, 42L))
  > 
  > res <- tryCatch({
  +   seed <- as_lecyer_cmrg_seed(seed = FALSE)
  + }, error = identity)
  > print(res)
  <simpleError in as_lecyer_cmrg_seed(seed = FALSE): Argument 'seed' must be TRUE if logical: FALSE>
  > stopifnot(inherits(res, "simpleError"))
  > 
  > seed <- as_lecyer_cmrg_seed(seed = 42L)
  Warning in RNGkind("L'Ecuyer-CMRG") :
    '.Random.seed[1]' is not a valid RNG kind so ignored
  > str(seed)
   int [1:7] 10407 -2133391687 507561766 1260545903 1362917092 -1772566379 -1344458670
  > set_random_seed(seed = seed)
  > stopifnot(identical(get_random_seed(), seed))
  > 
  > seed2 <- as_lecyer_cmrg_seed(seed = TRUE)
  > str(seed2)
   int [1:7] 10407 1279540750 -941988041 -2007404020 745992093 -1794778694 2071448563
  > stopifnot(identical(seed2, seed))
  Error: identical(seed2, seed) is not TRUE
  Execution halted