From 619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 22 Feb 2022 17:03:21 +0100 Subject: Initial self-hosting commit This is the initial version of our tool that is able to build itself. In can be bootstrapped by ./bin/bootstrap.py Co-authored-by: Oliver Reiche Co-authored-by: Victor Moreno --- .../buildtool/build_engine/base_maps/test_repo.hpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/buildtool/build_engine/base_maps/test_repo.hpp (limited to 'test/buildtool/build_engine/base_maps/test_repo.hpp') diff --git a/test/buildtool/build_engine/base_maps/test_repo.hpp b/test/buildtool/build_engine/base_maps/test_repo.hpp new file mode 100644 index 00000000..1269d2da --- /dev/null +++ b/test/buildtool/build_engine/base_maps/test_repo.hpp @@ -0,0 +1,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 + +#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 { + 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 -- cgit v1.2.3