diff options
25 files changed, 150 insertions, 90 deletions
diff --git a/src/buildtool/build_engine/target_map/built_in_rules.cpp b/src/buildtool/build_engine/target_map/built_in_rules.cpp index 18786b60..786b4d58 100644 --- a/src/buildtool/build_engine/target_map/built_in_rules.cpp +++ b/src/buildtool/build_engine/target_map/built_in_rules.cpp @@ -150,9 +150,7 @@ void FileGenRuleWithDeps( auto stage = ExpressionPtr{Expression::map_t{ file_name_val->String(), ExpressionPtr{ArtifactDescription{ - {HashFunction::ComputeBlobHash(data_val->String()).HexString(), - data_val->String().size()}, - ObjectType::File}}}}; + ArtifactDigest::Create(data_val->String()), ObjectType::File}}}}; auto vars_set = std::unordered_set<std::string>{}; vars_set.insert(param_vars->begin(), param_vars->end()); diff --git a/src/buildtool/build_engine/target_map/target_cache.cpp b/src/buildtool/build_engine/target_map/target_cache.cpp index d9fea021..8ba54557 100644 --- a/src/buildtool/build_engine/target_map/target_cache.cpp +++ b/src/buildtool/build_engine/target_map/target_cache.cpp @@ -23,8 +23,7 @@ auto TargetCache::Key::Create(BuildMaps::Base::EntityName const& target, {"effective_config", effective_config.ToString()}}}; static auto const& cas = LocalCAS<ObjectType::File>::Instance(); if (auto target_key = cas.StoreBlobFromBytes(target_desc.dump(2))) { - return Key{ - {ArtifactDigest{std::move(*target_key)}, ObjectType::File}}; + return Key{{ArtifactDigest{*target_key}, ObjectType::File}}; } } } catch (std::exception const& ex) { @@ -54,9 +53,9 @@ auto TargetCache::Entry::ToResult() const -> std::optional<TargetResult> { auto TargetCache::Store(Key const& key, Entry const& value) const noexcept -> bool { if (auto digest = CAS().StoreBlobFromBytes(value.ToJson().dump(2))) { - auto data = Artifact::ObjectInfo{ArtifactDigest{std::move(*digest)}, - ObjectType::File} - .ToString(); + auto data = + Artifact::ObjectInfo{ArtifactDigest{*digest}, ObjectType::File} + .ToString(); logger_.Emit(LogLevel::Debug, "Adding entry for key {} as {}", key.Id().ToString(), diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp index e3f203a9..35f38588 100644 --- a/src/buildtool/build_engine/target_map/target_map.cpp +++ b/src/buildtool/build_engine/target_map/target_map.cpp @@ -536,9 +536,7 @@ void withDependencies( } blobs.emplace_back(data->String()); return ExpressionPtr{ArtifactDescription{ - {HashFunction::ComputeBlobHash(data->String()).HexString(), - data->String().size()}, - ObjectType::File}}; + ArtifactDigest::Create(data->String()), ObjectType::File}}; }}, {"TREE", [&trees](auto&& eval, auto const& expr, auto const& env) { diff --git a/src/buildtool/common/TARGETS b/src/buildtool/common/TARGETS index 5d06723a..950f6347 100644 --- a/src/buildtool/common/TARGETS +++ b/src/buildtool/common/TARGETS @@ -35,6 +35,7 @@ [ "bazel_types" , ["src/buildtool/crypto", "hash_function"] , ["src/buildtool/file_system", "object_type"] + , ["src/buildtool/compatibility", "compatibility"] , ["src/utils/cpp", "type_safe_arithmetic"] , ["src/utils/cpp", "hash_combine"] , ["@", "json", "", "json"] diff --git a/src/buildtool/common/artifact.cpp b/src/buildtool/common/artifact.cpp index fc3c5b6e..0ff89c89 100644 --- a/src/buildtool/common/artifact.cpp +++ b/src/buildtool/common/artifact.cpp @@ -19,6 +19,7 @@ auto Artifact::ObjectInfo::LiberalFromString(std::string const& s) noexcept std::getline(iss, type, ']'); } auto size = static_cast<std::size_t>(std::atol(size_str.c_str())); - return Artifact::ObjectInfo{ArtifactDigest{id, size}, - FromChar(*type.c_str())}; + auto const& object_type = FromChar(*type.c_str()); + return Artifact::ObjectInfo{ + ArtifactDigest{id, size, IsTreeObject(object_type)}, object_type}; } diff --git a/src/buildtool/common/artifact.hpp b/src/buildtool/common/artifact.hpp index 3f68a351..a073b0d7 100644 --- a/src/buildtool/common/artifact.hpp +++ b/src/buildtool/common/artifact.hpp @@ -63,8 +63,10 @@ class Artifact { } try { std::size_t size = std::stoul(size_str); - return ObjectInfo{ArtifactDigest{id, size}, - FromChar(*type.c_str())}; + auto const& object_type = FromChar(*type.c_str()); + return ObjectInfo{ + ArtifactDigest{id, size, IsTreeObject(object_type)}, + object_type}; } catch (std::out_of_range const& e) { Logger::Log(LogLevel::Error, "size raised out_of_range exception."); @@ -79,10 +81,12 @@ class Artifact { -> std::optional<ObjectInfo> { if (j.is_object() and j["id"].is_string() and j["size"].is_number() and j["type"].is_string()) { - return ObjectInfo{ - ArtifactDigest{j["id"].get<std::string>(), - j["size"].get<std::size_t>()}, - FromChar(*(j["type"].get<std::string>().c_str()))}; + auto const& object_type = + FromChar(*(j["type"].get<std::string>().c_str())); + return ObjectInfo{ArtifactDigest{j["id"].get<std::string>(), + j["size"].get<std::size_t>(), + IsTreeObject(object_type)}, + object_type}; } return std::nullopt; } @@ -168,7 +172,8 @@ class Artifact { std::size_t size, ObjectType type, std::optional<std::string> const& repo) noexcept -> Artifact { - return Artifact{id, {hash, size}, type, false, repo}; + return Artifact{ + id, {hash, size, IsTreeObject(type)}, type, false, repo}; } [[nodiscard]] static auto CreateActionArtifact( diff --git a/src/buildtool/common/artifact_description.hpp b/src/buildtool/common/artifact_description.hpp index 81f7780e..923be83f 100644 --- a/src/buildtool/common/artifact_description.hpp +++ b/src/buildtool/common/artifact_description.hpp @@ -272,8 +272,10 @@ class ArtifactDescription { }); if (blob_id.has_value() and size.has_value() and file_type.has_value() and file_type->size() == 1) { - return ArtifactDescription{ArtifactDigest{*blob_id, *size}, - FromChar((*file_type)[0])}; + auto const& object_type = FromChar((*file_type)[0]); + return ArtifactDescription{ + ArtifactDigest{*blob_id, *size, IsTreeObject(object_type)}, + object_type}; } return std::nullopt; } diff --git a/src/buildtool/common/artifact_digest.hpp b/src/buildtool/common/artifact_digest.hpp index 92bbde92..fdb4648e 100644 --- a/src/buildtool/common/artifact_digest.hpp +++ b/src/buildtool/common/artifact_digest.hpp @@ -6,54 +6,78 @@ #include "gsl-lite/gsl-lite.hpp" #include "src/buildtool/common/bazel_types.hpp" +#include "src/buildtool/compatibility/native_support.hpp" #include "src/buildtool/crypto/hash_function.hpp" +#include "src/buildtool/file_system/object_type.hpp" #include "src/utils/cpp/hash_combine.hpp" -// Wrapper for bazel_re::Digest. Can be implicitly cast to bazel_re::Digest. -// Provides getter for size with convenient non-protobuf type. +// Provides getter for size with convenient non-protobuf type. Contains a +// unprefixed hex string as hash. For communication with the exeution API it can +// be cast to bazel_re::Digest which is the wire format that contains prefixed +// hashes in native mode. class ArtifactDigest { public: ArtifactDigest() noexcept = default; - explicit ArtifactDigest(bazel_re::Digest digest) noexcept + + explicit ArtifactDigest(bazel_re::Digest const& digest) noexcept : size_{gsl::narrow<std::size_t>(digest.size_bytes())}, - digest_{std::move(digest)} {} - ArtifactDigest(std::string hash, std::size_t size) noexcept - : size_{size}, digest_{CreateBazelDigest(std::move(hash), size)} {} + hash_{NativeSupport::Unprefix(digest.hash())}, + is_tree_{NativeSupport::IsTree(digest.hash())} {} + + ArtifactDigest(std::string hash, std::size_t size, bool is_tree) noexcept + : size_{size}, hash_{std::move(hash)}, is_tree_{is_tree} { + gsl_ExpectsAudit(not NativeSupport::IsPrefixed(hash_)); + } [[nodiscard]] auto hash() const& noexcept -> std::string const& { - return digest_.hash(); + return hash_; } [[nodiscard]] auto hash() && noexcept -> std::string { - return std::move(*digest_.mutable_hash()); + return std::move(hash_); } [[nodiscard]] auto size() const noexcept -> std::size_t { return size_; } + [[nodiscard]] auto is_tree() const noexcept -> bool { return is_tree_; } + // NOLINTNEXTLINE allow implicit casts - [[nodiscard]] operator bazel_re::Digest const &() const& { return digest_; } - // NOLINTNEXTLINE allow implicit casts - [[nodiscard]] operator bazel_re::Digest() && { return std::move(digest_); } + [[nodiscard]] operator bazel_re::Digest() const { + return CreateBazelDigest(hash_, size_, is_tree_); + } [[nodiscard]] auto operator==(ArtifactDigest const& other) const -> bool { return std::equal_to<bazel_re::Digest>{}(*this, other); } + template <ObjectType kType = ObjectType::File> [[nodiscard]] static auto Create(std::string const& content) noexcept -> ArtifactDigest { - return ArtifactDigest{ - HashFunction::ComputeBlobHash(content).HexString(), content.size()}; + if constexpr (kType == ObjectType::Tree) { + return ArtifactDigest{ + HashFunction::ComputeTreeHash(content).HexString(), + content.size(), + /*is_tree=*/true}; + } + else { + return ArtifactDigest{ + HashFunction::ComputeBlobHash(content).HexString(), + content.size(), + /*is_tree=*/false}; + } } private: std::size_t size_{}; - bazel_re::Digest digest_{}; + std::string hash_{}; + bool is_tree_{}; - [[nodiscard]] static auto CreateBazelDigest(std::string&& hash, - std::size_t size) + [[nodiscard]] static auto CreateBazelDigest(std::string const& hash, + std::size_t size, + bool is_tree) -> bazel_re::Digest { bazel_re::Digest d; - d.set_hash(std::move(hash)); + d.set_hash(NativeSupport::Prefix(hash, is_tree)); d.set_size_bytes(gsl::narrow<google::protobuf::int64>(size)); return d; } @@ -67,6 +91,7 @@ struct hash<ArtifactDigest> { std::size_t seed{}; hash_combine(&seed, digest.hash()); hash_combine(&seed, digest.size()); + hash_combine(&seed, digest.is_tree()); return seed; } }; diff --git a/src/buildtool/common/artifact_factory.hpp b/src/buildtool/common/artifact_factory.hpp index e3ef2d0c..9021f27c 100644 --- a/src/buildtool/common/artifact_factory.hpp +++ b/src/buildtool/common/artifact_factory.hpp @@ -45,7 +45,8 @@ class ArtifactFactory { std::string const& blob_id, std::size_t size, ObjectType type = ObjectType::File) noexcept -> nlohmann::json { - return ArtifactDescription{ArtifactDigest{blob_id, size}, type} + return ArtifactDescription{ + ArtifactDigest{blob_id, size, IsTreeObject(type)}, type} .ToJson(); } diff --git a/src/buildtool/common/repository_config.cpp b/src/buildtool/common/repository_config.cpp index ba45052a..eb41acaa 100644 --- a/src/buildtool/common/repository_config.cpp +++ b/src/buildtool/common/repository_config.cpp @@ -30,7 +30,7 @@ auto RepositoryConfig::RepositoryKey(std::string const& repo) const noexcept if (auto graph = BuildGraphForRepository(unique)) { auto& cas = LocalCAS<ObjectType::File>::Instance(); if (auto digest = cas.StoreBlobFromBytes(graph->dump(2))) { - return digest->hash(); + return ArtifactDigest{*digest}.hash(); } } return std::nullopt; diff --git a/src/buildtool/execution_api/local/local_ac.hpp b/src/buildtool/execution_api/local/local_ac.hpp index 08f384d8..c9659494 100644 --- a/src/buildtool/execution_api/local/local_ac.hpp +++ b/src/buildtool/execution_api/local/local_ac.hpp @@ -27,12 +27,14 @@ class LocalAC { auto bytes = result.SerializeAsString(); auto digest = cas_->StoreBlobFromBytes(bytes); return (digest and file_store_.AddFromBytes( - action_id.hash(), digest->SerializeAsString())); + NativeSupport::Unprefix(action_id.hash()), + digest->SerializeAsString())); } [[nodiscard]] auto CachedResult(bazel_re::Digest const& action_id) const noexcept -> std::optional<bazel_re::ActionResult> { - auto entry_path = file_store_.GetPath(action_id.hash()); + auto entry_path = + file_store_.GetPath(NativeSupport::Unprefix(action_id.hash())); bazel_re::Digest digest{}; auto const entry = FileSystemManager::ReadFile(entry_path, ObjectType::File); diff --git a/src/buildtool/execution_api/local/local_api.hpp b/src/buildtool/execution_api/local/local_api.hpp index 03f116a8..20886e5a 100644 --- a/src/buildtool/execution_api/local/local_api.hpp +++ b/src/buildtool/execution_api/local/local_api.hpp @@ -140,7 +140,7 @@ class LocalApi final : public IExecutionApi { } if (tree_map_->AddTree(*digest, std::move(tree))) { - return ArtifactDigest{std::move(*digest)}; + return ArtifactDigest{*digest}; } return std::nullopt; } diff --git a/src/buildtool/execution_api/local/local_cas.hpp b/src/buildtool/execution_api/local/local_cas.hpp index f8efbb6a..310a3011 100644 --- a/src/buildtool/execution_api/local/local_cas.hpp +++ b/src/buildtool/execution_api/local/local_cas.hpp @@ -41,11 +41,12 @@ class LocalCAS { [[nodiscard]] auto BlobPath(bazel_re::Digest const& digest) const noexcept -> std::optional<std::filesystem::path> { - auto blob_path = file_store_.GetPath(digest.hash()); + auto id = NativeSupport::Unprefix(digest.hash()); + auto blob_path = file_store_.GetPath(id); if (FileSystemManager::IsFile(blob_path)) { return blob_path; } - logger_.Emit(LogLevel::Debug, "Blob not found {}", digest.hash()); + logger_.Emit(LogLevel::Debug, "Blob not found {}", id); return std::nullopt; } @@ -90,7 +91,8 @@ class LocalCAS { -> std::optional<bazel_re::Digest> { auto digest = CreateDigest(data); if (digest) { - if (StoreBlobData(digest->hash(), data, is_owner)) { + if (StoreBlobData( + NativeSupport::Unprefix(digest->hash()), data, is_owner)) { return digest; } logger_.Emit( diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index 9e83129a..721d4896 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -221,9 +221,7 @@ class ExecutorImpl { if (not content.has_value()) { return std::nullopt; } - auto digest = - ArtifactDigest{HashFunction::ComputeBlobHash(*content).HexString(), - content->size()}; + auto digest = ArtifactDigest::Create(*content); if (not api->Upload( BlobContainer{{BazelBlob{digest, std::move(*content)}}})) { return std::nullopt; diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index 747ca896..872ae1ff 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -399,6 +399,7 @@ class FileRoot { } // Create LOCAL or KNOWN artifact. Does not check existence for LOCAL. + // `file_path` must reference a blob. [[nodiscard]] auto ToArtifactDescription( std::filesystem::path const& file_path, std::string const& repository) const noexcept @@ -412,11 +413,14 @@ class FileRoot { auto compatible_hash = Compatibility::RegisterGitEntry( entry->Hash(), *entry->Blob(), repository); return ArtifactDescription{ - ArtifactDigest{compatible_hash, *entry->Size()}, + ArtifactDigest{compatible_hash, + *entry->Size(), + /*is_tree=*/false}, entry->Type()}; } return ArtifactDescription{ - ArtifactDigest{entry->Hash(), *entry->Size()}, + ArtifactDigest{ + entry->Hash(), *entry->Size(), /*is_tree=*/false}, entry->Type(), repository}; } diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp index c00fe61b..e61a7280 100644 --- a/src/buildtool/graph_traverser/graph_traverser.hpp +++ b/src/buildtool/graph_traverser/graph_traverser.hpp @@ -261,8 +261,7 @@ class GraphTraverser { std::vector<std::string> const& blobs) const noexcept -> bool { BlobContainer container; for (auto const& blob : blobs) { - auto digest = ArtifactDigest{ - HashFunction::ComputeBlobHash(blob).HexString(), blob.size()}; + auto digest = ArtifactDigest::Create(blob); Logger::Log(LogLevel::Trace, [&]() { return fmt::format( "Uploaded blob {}, its digest has id {} and size {}.", diff --git a/test/buildtool/common/artifact_description.test.cpp b/test/buildtool/common/artifact_description.test.cpp index b1522198..1d8c70a9 100644 --- a/test/buildtool/common/artifact_description.test.cpp +++ b/test/buildtool/common/artifact_description.test.cpp @@ -20,16 +20,17 @@ TEST_CASE("Local artifact", "[artifact_description]") { TEST_CASE("Known artifact", "[artifact_description]") { SECTION("File object") { auto known_desc = ArtifactDescription{ - ArtifactDigest{std::string{"f_fake_hash"}, 0}, ObjectType::File}; + ArtifactDigest{std::string{"f_fake_hash"}, 0, /*is_tree=*/false}, + ObjectType::File}; auto known = known_desc.ToArtifact(); auto known_from_factory = ArtifactFactory::FromDescription(known_desc.ToJson()); CHECK(known == *known_from_factory); } SECTION("Executable object") { - auto known_desc = - ArtifactDescription{ArtifactDigest{std::string{"x_fake_hash"}, 1}, - ObjectType::Executable}; + auto known_desc = ArtifactDescription{ + ArtifactDigest{std::string{"x_fake_hash"}, 1, /*is_tree=*/false}, + ObjectType::Executable}; auto known = known_desc.ToArtifact(); auto known_from_factory = ArtifactFactory::FromDescription(known_desc.ToJson()); diff --git a/test/buildtool/common/repository_config.test.cpp b/test/buildtool/common/repository_config.test.cpp index 19ab25c2..bd2a0e0b 100644 --- a/test/buildtool/common/repository_config.test.cpp +++ b/test/buildtool/common/repository_config.test.cpp @@ -59,7 +59,8 @@ template <class T> // Read graph from CAS [[nodiscard]] auto ReadGraph(std::string const& hash) -> nlohmann::json { auto& cas = LocalCAS<ObjectType::File>::Instance(); - auto blob = cas.BlobPath(ArtifactDigest{hash, /*does not matter*/ 0}); + auto blob = cas.BlobPath( + ArtifactDigest{hash, /*does not matter*/ 0, /*is_tree=*/false}); REQUIRE(blob); auto content = FileSystemManager::ReadFile(*blob); REQUIRE(content); diff --git a/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp b/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp index f0246fd7..79cc8ffa 100755 --- a/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_execution_client.test.cpp @@ -11,7 +11,8 @@ TEST_CASE("Bazel internals: Execution Client", "[execution_api]") { std::string instance_name{"remote-execution"}; std::string content("test"); - auto test_digest = ArtifactDigest::Create(content); + auto test_digest = + static_cast<bazel_re::Digest>(ArtifactDigest::Create(content)); BazelExecutionClient execution_client(info->host, info->port); @@ -78,7 +79,8 @@ TEST_CASE("Bazel internals: Execution Client using env variables", std::string instance_name{"remote-execution"}; std::string content("contents of env variable"); - auto test_digest = ArtifactDigest::Create(content); + auto test_digest = + static_cast<bazel_re::Digest>(ArtifactDigest::Create(content)); BazelExecutionClient execution_client(info->host, info->port); diff --git a/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp b/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp index 050af817..9763e693 100644 --- a/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_msg_factory.test.cpp @@ -29,7 +29,7 @@ TEST_CASE("Bazel internals: MessageFactory", "[execution_api]") { // create known artifacts auto artifact1_opt = ArtifactFactory::FromDescription(ArtifactFactory::DescribeKnownArtifact( - file1_blob->digest.hash(), + NativeSupport::Unprefix(file1_blob->digest.hash()), static_cast<std::size_t>(file1_blob->digest.size_bytes()), ObjectType::File)); CHECK(artifact1_opt.has_value()); @@ -37,7 +37,7 @@ TEST_CASE("Bazel internals: MessageFactory", "[execution_api]") { auto artifact2_opt = ArtifactFactory::FromDescription(ArtifactFactory::DescribeKnownArtifact( - file2_blob->digest.hash(), + NativeSupport::Unprefix(file2_blob->digest.hash()), static_cast<std::size_t>(file2_blob->digest.size_bytes()), ObjectType::File)); CHECK(artifact2_opt.has_value()); diff --git a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp index 3187c99c..6ce67e53 100644 --- a/test/buildtool/execution_api/bazel/bytestream_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bytestream_client.test.cpp @@ -18,18 +18,21 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { std::string content("foobar"); // digest of "foobar" - auto digest = ArtifactDigest::Create(content); + auto digest = + static_cast<bazel_re::Digest>(ArtifactDigest::Create(content)); CHECK(stream.Write(fmt::format("{}/uploads/{}/blobs/{}/{}", instance_name, uuid, digest.hash(), - digest.size()), + digest.size_bytes()), content)); SECTION("Download small blob") { - auto data = stream.Read(fmt::format( - "{}/blobs/{}/{}", instance_name, digest.hash(), digest.size())); + auto data = stream.Read(fmt::format("{}/blobs/{}/{}", + instance_name, + digest.hash(), + digest.size_bytes())); CHECK(data == content); } @@ -44,25 +47,31 @@ TEST_CASE("ByteStream Client: Transfer single blob", "[execution_api]") { } // digest of "instance_nameinstance_nameinstance_..." - auto digest = ArtifactDigest::Create(content); + auto digest = + static_cast<bazel_re::Digest>(ArtifactDigest::Create(content)); CHECK(stream.Write(fmt::format("{}/uploads/{}/blobs/{}/{}", instance_name, uuid, digest.hash(), - digest.size()), + digest.size_bytes()), content)); SECTION("Download large blob") { - auto data = stream.Read(fmt::format( - "{}/blobs/{}/{}", instance_name, digest.hash(), digest.size())); + auto data = stream.Read(fmt::format("{}/blobs/{}/{}", + instance_name, + digest.hash(), + digest.size_bytes())); CHECK(data == content); } SECTION("Incrementally download large blob") { - auto reader = stream.IncrementalRead(fmt::format( - "{}/blobs/{}/{}", instance_name, digest.hash(), digest.size())); + auto reader = + stream.IncrementalRead(fmt::format("{}/blobs/{}/{}", + instance_name, + digest.hash(), + digest.size_bytes())); std::string data{}; auto chunk = reader.Next(); diff --git a/test/buildtool/execution_api/local_tree_map.test.cpp b/test/buildtool/execution_api/local_tree_map.test.cpp index d8becced..9b9f2da4 100644 --- a/test/buildtool/execution_api/local_tree_map.test.cpp +++ b/test/buildtool/execution_api/local_tree_map.test.cpp @@ -9,11 +9,13 @@ namespace { [[nodiscard]] auto ToDigest(std::string const& s) { - return static_cast<bazel_re::Digest>(ArtifactDigest{s, 0}); + return static_cast<bazel_re::Digest>( + ArtifactDigest{s, 0, /*is_tree=*/false}); } [[nodiscard]] auto ToInfo(std::string const& s) { - return Artifact::ObjectInfo{ArtifactDigest{s, 0}, ObjectType::File}; + return Artifact::ObjectInfo{ArtifactDigest{s, 0, /*is_tree=*/false}, + ObjectType::File}; } } // namespace diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp index 3e56909e..e055dfd7 100755 --- a/test/buildtool/execution_engine/executor/executor.test.cpp +++ b/test/buildtool/execution_engine/executor/executor.test.cpp @@ -63,9 +63,11 @@ class TestResponse : public IExecutionResponse { // collect files and store them for (auto const& path : config_.execution.outputs) { try { - artifacts.emplace(path, - Artifact::ObjectInfo{ArtifactDigest{path, 0}, - ObjectType::File}); + artifacts.emplace( + path, + Artifact::ObjectInfo{ + ArtifactDigest{path, 0, /*is_tree=*/false}, + ObjectType::File}); } catch (...) { return {}; } @@ -170,8 +172,8 @@ static void SetupConfig(std::filesystem::path const& ws) { SetupConfig(ws); auto const local_cpp_desc = ArtifactDescription{path{"local.cpp"}, ""}; - auto const known_cpp_desc = - ArtifactDescription{ArtifactDigest{"known.cpp", 0}, ObjectType::File}; + auto const known_cpp_desc = ArtifactDescription{ + ArtifactDigest{"known.cpp", 0, /*is_tree=*/false}, ObjectType::File}; auto const test_action_desc = ActionDescription{ {"output1.exe", "output2.exe"}, diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp index d1b13ee5..4fe06aa1 100755 --- a/test/buildtool/execution_engine/executor/executor_api.test.hpp +++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp @@ -28,7 +28,8 @@ static inline void RunBlobUpload(ApiFactory const& factory) { std::string const blob = "test"; CHECK(api->Upload(BlobContainer{{BazelBlob{ ArtifactDigest{HashFunction::ComputeBlobHash(blob).HexString(), - blob.size()}, + blob.size(), + /*is_tree=*/false}, blob}}})); } @@ -273,10 +274,14 @@ static inline void TestUploadAndDownloadTrees(ApiFactory const& factory, auto foo = std::string{"foo"}; auto bar = std::string{"bar"}; - auto foo_digest = ArtifactDigest{ - HashFunction::ComputeBlobHash(foo).HexString(), foo.size()}; - auto bar_digest = ArtifactDigest{ - HashFunction::ComputeBlobHash(bar).HexString(), bar.size()}; + auto foo_digest = + ArtifactDigest{HashFunction::ComputeBlobHash(foo).HexString(), + foo.size(), + /*is_tree=*/false}; + auto bar_digest = + ArtifactDigest{HashFunction::ComputeBlobHash(bar).HexString(), + bar.size(), + /*is_tree=*/false}; // upload blobs auto api = factory(); diff --git a/test/buildtool/file_system/file_root.test.cpp b/test/buildtool/file_system/file_root.test.cpp index b776b5e3..cda77859 100644 --- a/test/buildtool/file_system/file_root.test.cpp +++ b/test/buildtool/file_system/file_root.test.cpp @@ -212,14 +212,17 @@ TEST_CASE("Creating artifact descriptions", "[file_root]") { auto foo = root->ToArtifactDescription("baz/foo", "repo"); REQUIRE(foo); - CHECK(*foo == ArtifactDescription{ - ArtifactDigest{kFooId, 3}, ObjectType::File, "repo"}); + CHECK(*foo == + ArtifactDescription{ArtifactDigest{kFooId, 3, /*is_tree=*/false}, + ObjectType::File, + "repo"}); auto bar = root->ToArtifactDescription("baz/baz/bar", "repo"); REQUIRE(bar); - CHECK(*bar == ArtifactDescription{ArtifactDigest{kBarId, 3}, - ObjectType::Executable, - "repo"}); + CHECK(*bar == + ArtifactDescription{ArtifactDigest{kBarId, 3, /*is_tree=*/false}, + ObjectType::Executable, + "repo"}); CHECK_FALSE(root->ToArtifactDescription("baz", "repo")); CHECK_FALSE(root->ToArtifactDescription("does_not_exist", "repo")); |