CleanupReporter {ps}R Documentation

testthat reporter that checks if child processes are cleaned up in tests

Description

CleanupReporter takes an existing testthat Reporter object, and wraps it, so it checks for leftover child processes, at the specified place, see the proc_unit argument below.

Usage

CleanupReporter(reporter = testthat::ProgressReporter)

Arguments

reporter

A testthat reporter to wrap into a new CleanupReporter class.

Details

Child processes can be reported via a failed expectation, cleaned up silently, or cleaned up and reported (the default).

The constructor of the CleanupReporter class has options:

Value

New reporter class that behaves exactly like reporter, but it checks for, and optionally cleans up child processes, at the specified granularity.

Examples

This is how to use this reporter in testthat.R:

library(testthat)
library(mypackage)

if  (ps::ps_is_supported()) {
  reporter <- ps::CleanupReporter(testthat::ProgressReporter)$new(
    proc_unit = "test", proc_cleanup = TRUE)
} else {
  ## ps does not support this platform
  reporter <- "progress"
}

test_check("mypackage", reporter = reporter)

Note

Some IDEs, like RStudio, start child processes frequently, and sometimes crash when these are killed, only use this reporter in a terminal session. In particular, you can always use it in the idiomatic testthat.R file, that calls test_check() during ⁠R CMD check⁠.


[Package ps version 1.7.6 Index]