File: test-timeout.R

package info (click to toggle)
r-cran-sys 3.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 220 kB
  • sloc: ansic: 540; sh: 13; makefile: 2
file content (23 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
context("test-timeout")

test_that("exec timeout works", {
  if(.Platform$OS.type == "windows"){
    command = "ping"
    args = c("-n", "5", "localhost")
  } else {
    command = 'sleep'
    args = '5'
  }
  times <- system.time({
    expect_error(exec_wait(command, args, timeout = 1.50, std_out = FALSE), "timeout")
  })
  expect_gte(times[['elapsed']], 1.45)
  expect_lt(times[['elapsed']], 2.50)

  # Also try with exec_internal
  times <- system.time({
    expect_error(exec_internal(command, args, timeout = 0.50), "timeout")
  })
  expect_gte(times[['elapsed']], 0.45)
  expect_lt(times[['elapsed']], 1.50)
})