7#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_FILESYSTEM_CREATE_TEMPORARY_DIRECTORY_HPP_
8#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TESTING_FILESYSTEM_CREATE_TEMPORARY_DIRECTORY_HPP_
38class env_var_restorer {
40 std::string var_name_;
49 explicit env_var_restorer(std::string var_name)
52 if (
char const*
const old_val{getenv(var_name_.c_str())}) {
62 std::ignore = setenv(var_name_.c_str(), old_val_->c_str(), 1);
70 env_var_restorer(env_var_restorer
const&) =
delete;
72 env_var_restorer(env_var_restorer&&) =
delete;
74 auto operator=(env_var_restorer
const&) -> env_var_restorer& =
delete;
76 auto operator=(env_var_restorer&&) -> env_var_restorer& =
delete;
101 if (
char const*
const test_tmpdir{getenv(
"TEST_TMPDIR")}) {
103 detail::env_var_restorer
const restorer{
"TMPDIR"};
An RAII helper class to manage a temporary directory.
Definition temporary_directory.hpp:27
Implementation of std::optional for pre-C++17 compilers, and which replaces defined undefined behavio...
Definition optional.hpp:122
constexpr void emplace(Args &&... args) noexcept(noexcept(std::declval< optional< T > >().construct_from(std::forward< Args >(args)...)))
Destroy the old value if there is one, and construct a new value.
Definition optional.hpp:440
inline_string< PATH_MAX > path_string
An inline_string with storage large enough to hold a file path.
Definition path_string.hpp:21
Definition create_temporary_directory.hpp:31
auto create_temporary_directory() -> arene::base::filesystem::temporary_directory
construct a temporary directory within the test runtime
Definition create_temporary_directory.hpp:96
Definition customization.hpp:31
Definition accumulate.hpp:37
Definition accumulate.hpp:36
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
static constexpr auto const & ignore
An object to which anything can be assigned, which ignores the assigned value.
Definition ignore.hpp:72