atOnExit
Register Expression to Run at the End of an assertionTest

Description

A test file run by assertionTest often starts by creating some objects or files. Call atOnExit() right after creating those things to ensure they are removed when assertionTest is done.

Usage

atOnExit(expr)

Arguments

expr An unevaluated expression, typically one like rm(x) or unlink(file).

Details

The last expression to be registered will be run first. If one calls assertionTest(cleanup=FALSE,...) then the expression in atOnExit will not be run at the conclusion of assertionTest.
Value
It always returns TRUE.
See Also
assertionTest
Examples
  # Put the following in a test.t file and run it with assertionTest:
  { testx <- log(1:10) ; file <- tempfile()
    atOnExit({unlink(file);rm(testx,file)}) }
  {
    writeBin(testx, file)
    atOnExit(rm(testy)) ;
    testy <- readBin(file, what=numeric(), n=length(testx))
    identical(testx, testy)
  }
  # see example test files in assertionTest/test-ex
  assertionTest(system.file(package="assertionTest", "test-ex", "clean.t"))
Package assertionTest version 6.1.4-13
Package Index