19 static const std::string chars =
"abcdefghijklmnopqrstuvwxyz0123456789";
20 static thread_local std::mt19937 generator{std::random_device{}()};
21 std::uniform_int_distribution<std::size_t> distribution(0, chars.size() - 1);
24 constexpr std::size_t random_name_length = 10;
25 result.reserve(random_name_length);
26 while (result.size() < random_name_length)
27 result += chars[distribution(generator)];
28 return std::filesystem::temp_directory_path() / std::filesystem::path(
"mooseunit." + result);
39 std::filesystem::remove(
path(), ec);
43 : _original_path(
std::filesystem::current_path()), _path(createPath())
47 for (
const auto & input : inputs)
48 std::filesystem::copy(
49 input,
_path / input.filename(), std::filesystem::copy_options::recursive);
50 std::filesystem::current_path(
_path);
55 std::filesystem::remove_all(
_path, ec);
65 std::filesystem::remove_all(
_path, ec);
73 const auto path = generatePath();
74 if (std::filesystem::create_directory(
path))
const std::filesystem::path _original_path
Working directory to restore upon destruction.
static std::filesystem::path createPath()
ScopedTestDirectory(const std::vector< std::filesystem::path > &inputs)
const std::filesystem::path _path
Unique temporary working directory.
const std::filesystem::path & path() const
const std::filesystem::path & path() const