tests/testthat/test-timeout.R

context("timeout")

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()
})
r-pkgs/callr documentation built on Dec. 13, 2018, 12:21 p.m.