13 #ifndef __STOUT_TESTS_UTILS_HPP__ 14 #define __STOUT_TESTS_UTILS_HPP__ 18 #include <gtest/gtest.h> 60 return Error(
"Failed to mkdtemp: " + directory.
error());
70 if (realpath.isError()) {
71 return Error(
"Failed to get realpath of '" + directory.
get() +
"'" 72 ": " + realpath.error());
73 }
else if (realpath.isNone()) {
74 return Error(
"Failed to get realpath of '" + directory.
get() +
"'" 75 ": No such directory");
84 return Error(
"Failed to chdir into '" + sandbox.get() +
"'" 85 ": " + chdir.
error());
97 return Error(
"Failed to chdir into '" + cwd +
"': " + chdir.
error());
104 ": " + rmdir.
error());
125 inline bool isJailed() {
128 ::sysctlnametomib(
"security.jail.jailed", mib, &len);
131 return jailed.
get() == 1;
138 #endif // __STOUT_TESTS_UTILS_HPP__ Try< Nothing > SetUpMixin()
Definition: utils.hpp:51
Try< Nothing > rmdir(const std::string &directory, bool recursive=true, bool removeRoot=true, bool continueOnError=false)
Definition: rmdir.hpp:42
Definition: nothing.hpp:16
Definition: errorbase.hpp:36
T & get()&
Definition: try.hpp:80
Result< std::string > realpath(const std::string &path)
Definition: realpath.hpp:24
std::string getcwd()
Definition: getcwd.hpp:23
bool isSome() const
Definition: option.hpp:116
Definition: utils.hpp:120
Option< std::string > sandbox
Definition: utils.hpp:113
void SetUp() override
Definition: utils.hpp:37
bool isSome() const
Definition: try.hpp:77
const T & get() const &
Definition: option.hpp:119
Integer integer() const
Definition: sysctl.hpp:182
static Try error(const E &e)
Definition: try.hpp:43
Try< Nothing > TearDownMixin()
Definition: utils.hpp:91
bool isError() const
Definition: try.hpp:78
Definition: sysctl.hpp:59
Try< Nothing > chdir(const std::string &directory)
Definition: chdir.hpp:25
#define ASSERT_SOME(actual)
Definition: gtest.hpp:128
Try< std::string > mkdtemp(const std::string &path=path::join(os::temp(),"XXXXXX"))
Definition: mkdtemp.hpp:38
void TearDown() override
Definition: utils.hpp:44