From 9abfd2b14bbaa7cdd4711f56f70f941109e62e54 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Fri, 10 Mar 2023 19:08:41 +0100 Subject: Remote Tests: Ensure writable build root exists --- test/utils/remote_execution/main-remote-execution.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/utils/remote_execution/main-remote-execution.cpp') diff --git a/test/utils/remote_execution/main-remote-execution.cpp b/test/utils/remote_execution/main-remote-execution.cpp index 188d3eea..703de7f4 100644 --- a/test/utils/remote_execution/main-remote-execution.cpp +++ b/test/utils/remote_execution/main-remote-execution.cpp @@ -22,6 +22,8 @@ #include "catch2/catch.hpp" #include "src/buildtool/compatibility/compatibility.hpp" #include "src/buildtool/execution_api/remote/config.hpp" +#include "src/buildtool/file_system/file_system_manager.hpp" +#include "src/buildtool/storage/storage.hpp" #include "test/utils/logging/log_config.hpp" #include "test/utils/test_env.hpp" @@ -58,11 +60,27 @@ void wait_for_grpc_to_shutdown() { return static_cast(RemoteExecutionConfig::RemoteAddress()); } +[[nodiscard]] auto ConfigureBuildRoot() -> bool { + auto cache_dir = FileSystemManager::GetCurrentDirectory() / "cache"; + if (not FileSystemManager::CreateDirectoryExclusive(cache_dir) or + not StorageConfig::SetBuildRoot(cache_dir)) { + return false; + } + // After the build root has been changed, the file roots of the + // static storage instances need to be updated. + Storage::Reinitialize(); + return true; +} + } // namespace auto main(int argc, char* argv[]) -> int { ConfigureLogging(); + if (not ConfigureBuildRoot()) { + return EXIT_FAILURE; + } + if (not ConfigureRemoteExecution()) { return EXIT_FAILURE; } -- cgit v1.2.3