File: test-cleanup.R

package info (click to toggle)
r-cran-processx 3.8.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,068 kB
  • sloc: ansic: 6,485; sh: 13; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 440 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

test_that("process is cleaned up", {

  px <- get_tool("px")
  p <- process$new(px, c("sleep", "1"), cleanup = TRUE)
  pid <- p$get_pid()

  rm(p)
  gc()

  expect_false(process__exists(pid))
})

test_that("process can stay alive", {

  px <- get_tool("px")

  on.exit(tools::pskill(pid, 9), add = TRUE)
  p <- process$new(px, c("sleep", "60"), cleanup = FALSE)
  pid <- p$get_pid()

  rm(p)
  gc()

  expect_true(process__exists(pid))
})