eckit::testing::SetEnv class

RAII guard that sets an environment variable and restores its original state on destruction.

On construction, saves the current value of the named environment variable (if any) and sets it to the given value. On destruction, restores the original value or unsets the variable if it was not previously defined.

Constructors, destructors, conversion operators

SetEnv(std::string key, std::string val)
~SetEnv()
SetEnv(const SetEnv&) deleted
SetEnv(SetEnv&&) deleted

Public functions

auto operator=(const SetEnv&) -> SetEnv& deleted
auto operator=(SetEnv&&) -> SetEnv& deleted

Function documentation

eckit::testing::SetEnv::SetEnv(std::string key, std::string val)

Parameters
key Name of the environment variable to set.
val Value to assign to the environment variable.
Exceptions
eckit::SyscallException if setenv() fails.