diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-28 16:56:16 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-02-07 14:58:04 +0100 |
commit | 0ce9e40d44834e9590e0a74e63ea19274fa7f2bb (patch) | |
tree | dba710ea3f8a82c186e524961e3aab7d93f31ade /test | |
parent | e2f73a93be5977b5e18f4ba3aa05ea31bc5c16c4 (diff) | |
download | justbuild-0ce9e40d44834e9590e0a74e63ea19274fa7f2bb.tar.gz |
BazelNetwork: Drop iterators in DoUploadBlobs
Diffstat (limited to 'test')
-rw-r--r-- | test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp | 4 | ||||
-rw-r--r-- | test/utils/remote_execution/bazel_action_creator.hpp | 22 |
2 files changed, 10 insertions, 16 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp index b6cc24d3..493d2f28 100644 --- a/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_cas_client.test.cpp @@ -68,7 +68,7 @@ TEST_CASE("Bazel internals: CAS Client", "[execution_api]") { if (not digests.empty()) { // Upload blob, if not found - std::vector<gsl::not_null<BazelBlob const*>> to_upload{&blob}; + std::unordered_set<BazelBlob> to_upload{blob}; CHECK(cas_client.BatchUpdateBlobs( instance_name, to_upload.begin(), to_upload.end()) == 1U); } @@ -97,7 +97,7 @@ TEST_CASE("Bazel internals: CAS Client", "[execution_api]") { .size() == 1); // Try upload faulty blob - std::vector<gsl::not_null<BazelBlob const*>> to_upload{&faulty_blob}; + std::unordered_set<BazelBlob> to_upload{faulty_blob}; CHECK(cas_client.BatchUpdateBlobs( instance_name, to_upload.begin(), to_upload.end()) == 0U); diff --git a/test/utils/remote_execution/bazel_action_creator.hpp b/test/utils/remote_execution/bazel_action_creator.hpp index 1499424c..44315cea 100644 --- a/test/utils/remote_execution/bazel_action_creator.hpp +++ b/test/utils/remote_execution/bazel_action_creator.hpp @@ -16,11 +16,13 @@ #define INCLUDED_SRC_TEST_UTILS_REMOTE_EXECUTION_ACTION_CREATOR_HPP #include <algorithm> // std::transform, std::copy +#include <functional> #include <iterator> #include <map> #include <memory> #include <optional> #include <string> +#include <unordered_set> #include <vector> #include "google/protobuf/repeated_ptr_field.h" @@ -51,7 +53,7 @@ *(platform->add_properties()) = property; } - std::vector<BazelBlob> blobs; + std::unordered_set<BazelBlob> blobs; bazel_re::Command cmd; cmd.set_allocated_platform(platform.release()); @@ -71,13 +73,13 @@ auto cmd_data = cmd.SerializeAsString(); auto cmd_id = BazelDigestFactory::HashDataAs<ObjectType::File>( hash_function, cmd_data); - blobs.emplace_back(cmd_id, cmd_data, /*is_exec=*/false); + blobs.emplace(cmd_id, cmd_data, /*is_exec=*/false); bazel_re::Directory empty_dir; auto dir_data = empty_dir.SerializeAsString(); auto dir_id = BazelDigestFactory::HashDataAs<ObjectType::Tree>( hash_function, dir_data); - blobs.emplace_back(dir_id, dir_data, /*is_exec=*/false); + blobs.emplace(dir_id, dir_data, /*is_exec=*/false); bazel_re::Action action; (*action.mutable_command_digest()) = cmd_id; @@ -87,7 +89,7 @@ auto action_data = action.SerializeAsString(); auto action_id = BazelDigestFactory::HashDataAs<ObjectType::File>( hash_function, action_data); - blobs.emplace_back(action_id, action_data, /*is_exec=*/false); + blobs.emplace(action_id, action_data, /*is_exec=*/false); auto auth_config = TestAuthConfig::ReadFromEnvironment(); if (not auth_config) { @@ -106,16 +108,8 @@ &*auth_config, &retry_config); - std::vector<gsl::not_null<BazelBlob const*>> blob_ptrs; - blob_ptrs.reserve(blobs.size()); - std::transform(blobs.begin(), - blobs.end(), - std::back_inserter(blob_ptrs), - [](BazelBlob const& b) { return &b; }); - - if (cas_client.BatchUpdateBlobs(instance_name, - blob_ptrs.begin(), - blob_ptrs.end()) == blobs.size()) { + if (cas_client.BatchUpdateBlobs( + instance_name, blobs.begin(), blobs.end()) == blobs.size()) { return std::make_unique<bazel_re::Digest>(action_id); } return nullptr; |