tests/testthat/helper-parallel.R

with_parallel <- function(code) {
  cores <- as.numeric(Sys.getenv("TEST_CORES"))
  if (is.na(cores)) cores <- 1
  if (require("doParallel", quietly = TRUE) && cores > 1) {
    doParallel::registerDoParallel(cores = cores)
    on.exit(doParallel::stopImplicitCluster())
  }

  code
}

Try the MachineShop package in your browser

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

MachineShop documentation built on June 10, 2025, 1:08 a.m.