diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-02-22 17:03:21 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-02-22 17:03:21 +0100 |
commit | 619def44c1cca9f3cdf63544d5f24f2c7a7d9b77 (patch) | |
tree | 01868de723cb82c86842f33743fa7b14e24c1fa3 /test/buildtool/build_engine/base_maps/test_repo.hpp | |
download | justbuild-619def44c1cca9f3cdf63544d5f24f2c7a7d9b77.tar.gz |
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 <oliver.reiche@huawei.com>
Co-authored-by: Victor Moreno <victor.moreno1@huawei.com>
Diffstat (limited to 'test/buildtool/build_engine/base_maps/test_repo.hpp')
-rw-r--r-- | test/buildtool/build_engine/base_maps/test_repo.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
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 <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 |