summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/TARGETS1
-rw-r--r--test/main.cpp16
2 files changed, 17 insertions, 0 deletions
diff --git a/test/TARGETS b/test/TARGETS
index 9054bd75..a39b6e92 100644
--- a/test/TARGETS
+++ b/test/TARGETS
@@ -6,6 +6,7 @@
[ ["@", "catch2", "", "catch2"]
, ["utils", "log_config"]
, ["@", "src", "src/buildtool/file_system", "git_context"]
+ , ["@", "src", "src/buildtool/storage", "config"]
]
, "stage": ["test"]
}
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);
}