tests/testthat/test-timeout.R

test_that("r with timeout", {
  tic <- Sys.time()
  e <- tryCatch(
    r(function() Sys.sleep(5), timeout = 1),
    error = function(e) e
  )
  tac <- Sys.time()

  expect_true("callr_timeout_error" %in% class(e))
  expect_true(tac - tic < as.difftime(4, units = "secs"))
  gc()
})
MangoTheCat/callr documentation built on March 26, 2024, 11:23 a.m.