diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-08-29 11:35:37 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-08-30 17:17:09 +0200 |
commit | d551ef4acdf1732a145724b70f65be5fbe4052b0 (patch) | |
tree | 0cd3d2da73907d5d142b6b8c6b92304ed0a9a17e /test/buildtool/storage | |
parent | 8520a8fe2b2fc20940ed6457971a8de179343449 (diff) | |
download | justbuild-d551ef4acdf1732a145724b70f65be5fbe4052b0.tar.gz |
Replace bazel_re::Digest in LocalCAS::{...}Path
...with ArtifactDigest.
Diffstat (limited to 'test/buildtool/storage')
-rw-r--r-- | test/buildtool/storage/large_object_cas.test.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/test/buildtool/storage/large_object_cas.test.cpp b/test/buildtool/storage/large_object_cas.test.cpp index 7d191629..2b993b04 100644 --- a/test/buildtool/storage/large_object_cas.test.cpp +++ b/test/buildtool/storage/large_object_cas.test.cpp @@ -58,7 +58,7 @@ class Blob final { LocalCAS<kDefaultDoGlobalUplink> const& cas, std::string const& id, std::uintmax_t size) noexcept - -> std::optional<std::pair<bazel_re::Digest, std::filesystem::path>>; + -> std::optional<std::pair<ArtifactDigest, std::filesystem::path>>; [[nodiscard]] static auto Generate(std::string const& id, std::uintmax_t size) noexcept @@ -82,7 +82,7 @@ class Tree final { LocalCAS<kDefaultDoGlobalUplink> const& cas, std::string const& id, std::uintmax_t entries_count) noexcept - -> std::optional<std::pair<bazel_re::Digest, std::filesystem::path>>; + -> std::optional<std::pair<ArtifactDigest, std::filesystem::path>>; [[nodiscard]] static auto Generate(std::string const& id, std::uintmax_t entries_count) noexcept @@ -91,7 +91,7 @@ class Tree final { [[nodiscard]] static auto StoreRaw( LocalCAS<kDefaultDoGlobalUplink> const& cas, std::filesystem::path const& directory) noexcept - -> std::optional<bazel_re::Digest>; + -> std::optional<ArtifactDigest>; }; } // namespace LargeTestUtils @@ -243,7 +243,8 @@ static void TestSmall(Storage const& storage) noexcept { // The part of a small executable is the same file but without the // execution permission. It must be deleted too. if constexpr (kIsExec) { - auto part_path = cas.BlobPath(pack_1->front(), false); + auto part_path = cas.BlobPath( + static_cast<ArtifactDigest>(pack_1->front()), false); CHECK(part_path); CHECK(FileSystemManager::RemoveFile(*part_path)); } @@ -352,7 +353,8 @@ static void TestExternal(StorageConfig const& storage_config, REQUIRE(GarbageCollector::TriggerGarbageCollection(storage_config)); for (auto const& part : *pack_1) { static constexpr bool is_executable = false; - REQUIRE(cas.BlobPath(part, is_executable)); + REQUIRE( + cas.BlobPath(static_cast<ArtifactDigest>(part), is_executable)); } auto const youngest = ::Generation::Create(&storage_config); @@ -467,7 +469,7 @@ static void TestCompactification(StorageConfig const& storage_config, REQUIRE(FileSystemManager::Rename(invalid_path, *unique_path)); // Ensure all entries are in the storage: - auto get_path = [](auto const& cas, bazel_re::Digest const& digest) { + auto get_path = [](auto const& cas, ArtifactDigest const& digest) { return kIsTree ? cas.TreePath(digest) : cas.BlobPath(digest, kIsExec); }; @@ -651,7 +653,7 @@ template <bool IsExecutable> auto Blob<IsExecutable>::Create(LocalCAS<kDefaultDoGlobalUplink> const& cas, std::string const& id, std::uintmax_t size) noexcept - -> std::optional<std::pair<bazel_re::Digest, std::filesystem::path>> { + -> std::optional<std::pair<ArtifactDigest, std::filesystem::path>> { auto path = Generate(id, size); auto digest = path ? cas.StoreBlob(*path, IsExecutable) : std::nullopt; auto blob_path = @@ -678,7 +680,7 @@ auto Blob<IsExecutable>::Generate(std::string const& id, auto Tree::Create(LocalCAS<kDefaultDoGlobalUplink> const& cas, std::string const& id, std::uintmax_t entries_count) noexcept - -> std::optional<std::pair<bazel_re::Digest, std::filesystem::path>> { + -> std::optional<std::pair<ArtifactDigest, std::filesystem::path>> { auto path = Generate(id, entries_count); auto digest = path ? StoreRaw(cas, *path) : std::nullopt; auto cas_path = digest ? cas.TreePath(*digest) : std::nullopt; @@ -702,7 +704,7 @@ auto Tree::Generate(std::string const& id, auto Tree::StoreRaw(LocalCAS<kDefaultDoGlobalUplink> const& cas, std::filesystem::path const& directory) noexcept - -> std::optional<bazel_re::Digest> { + -> std::optional<ArtifactDigest> { if (not FileSystemManager::IsDirectory(directory)) { return std::nullopt; } @@ -720,11 +722,16 @@ auto Tree::StoreRaw(LocalCAS<kDefaultDoGlobalUplink> const& cas, return cas.StoreBlob(content); }; - return Compatibility::IsCompatible() - ? BazelMsgFactory::CreateDirectoryDigestFromLocalTree( - directory, store_blob, store_tree, store_symlink) - : BazelMsgFactory::CreateGitTreeDigestFromLocalTree( - directory, store_blob, store_tree, store_symlink); + auto bazel_digest = + Compatibility::IsCompatible() + ? BazelMsgFactory::CreateDirectoryDigestFromLocalTree( + directory, store_blob, store_tree, store_symlink) + : BazelMsgFactory::CreateGitTreeDigestFromLocalTree( + directory, store_blob, store_tree, store_symlink); + if (bazel_digest.has_value()) { + return static_cast<ArtifactDigest>(*bazel_digest); + } + return std::nullopt; } } // namespace LargeTestUtils |