Test helper to temporarily set sys env vars
Usage
local_sys_env_vars(vars, envir = parent.frame())
Arguments
- vars
A named character vector with names corresponding to vars that should be temporarily changed with the values they should be changed to.
- envir
The environment to use for scoping which must default to
parent.frame()
- do NOT changed this by supplying an alternative as this is used bywithr::defer()
.
Details
A call to local_sys_env_vars()
will alter the value of the specified system
environment variables and set up a deferred event to set them back to their
original values when the calling function exits (i.e., within the
appropriate scope as controlled by the envir
argument).
Examples
if (FALSE) { # \dontrun{
# For interactive use:
local_sys_env_vars(c(DIMEX_STORE = "xxx", DIMEX_STORE_REF = "yyy"))
# Run the deferred events to set the sys env vars back to their original
# values:
withr::deferred_run()
# Note: Use `withr::deferred_clear()` to clear the events without running
} # }