blob: 1269d2dae02dbf679cf6bf10376f5940e558bcdb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#ifndef INCLUDED_SRC_TEST_BUILDTOOL_BUILD_ENGINE_BASE_MAPS_TEST_REPO_HPP
#define INCLUDED_SRC_TEST_BUILDTOOL_BUILD_ENGINE_BASE_MAPS_TEST_REPO_HPP
#include <filesystem>
#include "src/buildtool/common/repository_config.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
static auto const kBasePath =
std::filesystem::path{"test/buildtool/build_engine/base_maps"};
static auto const kBundlePath = kBasePath / "data/test_repo.bundle";
static auto const kSrcTreeId =
std::string{"a35c324c6cf79354f6fd8a3c962f9ce7db801915"};
static auto const kRuleTreeId =
std::string{"c6dd902c9d4e7afa8b20eb04e58503e63ecab84d"};
static auto const kExprTreeId =
std::string{"4946bd21d0a5b3e0c82d6944f3d47adaf1bb66f7"};
static auto const kJsonTreeId =
std::string{"6982563dfc4dcdd1362792dbbc9d8243968d1ec9"};
[[nodiscard]] static inline auto GetTestDir() -> std::filesystem::path {
auto* tmp_dir = std::getenv("TEST_TMPDIR");
if (tmp_dir != nullptr) {
return tmp_dir;
}
return FileSystemManager::GetCurrentDirectory() / kBasePath;
}
[[nodiscard]] static inline auto CreateTestRepo()
-> std::optional<std::filesystem::path> {
auto repo_path = GetTestDir() / "test_repo" /
std::filesystem::path{std::tmpnam(nullptr)}.filename();
auto cmd = fmt::format(
"git clone --bare {} {}", kBundlePath.string(), repo_path.string());
if (std::system(cmd.c_str()) == 0) {
return repo_path;
}
return std::nullopt;
}
#endif // INCLUDED_SRC_TEST_BUILDTOOL_BUILD_ENGINE_BASE_MAPS_TEST_REPO_HPP
|