#pragma once // Scratch DOOS_HOME for the /doos route tests: a unique dir under the system // temp root (the example suite points TMPDIR at build/example/tmp), exported // before the Fixture builds the app, removed on teardown. #include #include #include namespace molo::example::test { struct ScratchDoosHome { std::filesystem::path dir; explicit ScratchDoosHome(const std::string& tag) { static int seq = 0; dir = std::filesystem::temp_directory_path() / ("molo-doos-route-" + tag + "-" + std::to_string(::getpid()) + "-" + std::to_string(seq++)); std::error_code ec; std::filesystem::remove_all(dir, ec); std::filesystem::create_directories(dir, ec); ::setenv("DOOS_HOME", dir.c_str(), 1); } ~ScratchDoosHome() { std::error_code ec; std::filesystem::remove_all(dir, ec); } }; } // namespace molo::example::test