From d551ef4acdf1732a145724b70f65be5fbe4052b0 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 29 Aug 2024 11:35:37 +0200 Subject: Replace bazel_re::Digest in LocalCAS::{...}Path ...with ArtifactDigest. --- test/buildtool/storage/large_object_cas.test.cpp | 35 ++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'test/buildtool/storage/large_object_cas.test.cpp') 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 const& cas, std::string const& id, std::uintmax_t size) noexcept - -> std::optional>; + -> std::optional>; [[nodiscard]] static auto Generate(std::string const& id, std::uintmax_t size) noexcept @@ -82,7 +82,7 @@ class Tree final { LocalCAS const& cas, std::string const& id, std::uintmax_t entries_count) noexcept - -> std::optional>; + -> std::optional>; [[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 const& cas, std::filesystem::path const& directory) noexcept - -> std::optional; + -> std::optional; }; } // 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(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(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 auto Blob::Create(LocalCAS const& cas, std::string const& id, std::uintmax_t size) noexcept - -> std::optional> { + -> std::optional> { auto path = Generate(id, size); auto digest = path ? cas.StoreBlob(*path, IsExecutable) : std::nullopt; auto blob_path = @@ -678,7 +680,7 @@ auto Blob::Generate(std::string const& id, auto Tree::Create(LocalCAS const& cas, std::string const& id, std::uintmax_t entries_count) noexcept - -> std::optional> { + -> std::optional> { 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 const& cas, std::filesystem::path const& directory) noexcept - -> std::optional { + -> std::optional { if (not FileSystemManager::IsDirectory(directory)) { return std::nullopt; } @@ -720,11 +722,16 @@ auto Tree::StoreRaw(LocalCAS 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(*bazel_digest); + } + return std::nullopt; } } // namespace LargeTestUtils -- cgit v1.2.3