generated from epiverse-trace/packagetemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d550a22
commit f70d2f4
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This helper ensures the package does not modify the session global state. As | ||
# per CRAN policy, packages should not interfere with the user's session state. | ||
# If global settings need to be modified, they should be restored to their | ||
# original values on exit. This can be achieved with the `on.exit()` base | ||
# function, or more conveniently with the `withr` package. | ||
# We add a test on R >= 4.0.0 because some functions such as | ||
# `globalCallingHandlers()` did not exist before. | ||
if (getRversion() >= "4.0.0") { | ||
testthat::set_state_inspector(function() { | ||
list( | ||
attached = search(), | ||
connections = getAllConnections(), | ||
cwd = getwd(), | ||
envvars = Sys.getenv(), | ||
handlers = globalCallingHandlers(), | ||
libpaths = .libPaths(), | ||
locale = Sys.getlocale(), | ||
options = options(), | ||
par = par(), | ||
packages = .packages(all.available = TRUE), | ||
sink = sink.number(), | ||
timezone = Sys.timezone(), | ||
NULL | ||
) | ||
}) | ||
} |