summaryrefslogtreecommitdiff
path: root/test/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/main.cpp')
-rw-r--r--test/main.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/main.cpp b/test/main.cpp
index bb431de2..1c685447 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -12,8 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#include <cstdlib>
+#include <filesystem>
+
#include "catch2/catch_session.hpp"
#include "src/buildtool/file_system/git_context.hpp"
+#include "src/buildtool/storage/config.hpp"
#include "test/utils/logging/log_config.hpp"
auto main(int argc, char* argv[]) -> int {
@@ -27,5 +31,17 @@ auto main(int argc, char* argv[]) -> int {
*/
GitContext::Create();
+ /**
+ * Test must not assume the existence of a home directory, nor write there.
+ * Hence we set the storage root to a fixed location under TEST_TMPDIR which
+ * is set by the test launcher.
+ */
+ auto setup_ok = StorageConfig::SetBuildRoot(
+ std::filesystem::path{std::string{std::getenv("TEST_TMPDIR")}} /
+ ".test_build_root");
+ if (not setup_ok) {
+ return 1;
+ }
+
return Catch::Session().run(argc, argv);
}