Save frmtmb's registries, and restore them when a test ends
Source:R/registries.R
frmtmb_local_registries.RdA test that registers a covariance structure, a residual correlation
term, an addition term, a family's compatibility rows, a frame check
or a prior default calls frmtmb_local_registries() first. When
env exits (the end of the test_that() block), every registry is
put back as it was, so the registration cannot reach the tests after
it: R CMD check and covr run every file of a suite in one session.
Usage
frmtmb_local_registries(env = parent.frame())Details
The restore puts back what it found. It never deletes an entry by
name, because the name may belong to a package that was loaded
before the test. A frmtmb package that loads inside the scope keeps
its registrations: after the restore, the .onLoad() of every
frmtmb.* namespace that appeared in the scope runs again, in the
order they loaded.
See also
frmtmb_register_covstruct(), frmtmb_register_autocor(),
frmtmb_register_aterm(), frmtmb_register_compat() and
frmtmb_register_frame_check(), the registrations it undoes.
Examples
f <- function() {
frmtmb_local_registries()
# a registration here is undone when f() returns
invisible(NULL)
}
f()