summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-18 17:51:41 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-23 10:54:50 +0200
commitdc1db0e8b43f5e907a3ded2e39da8b58fa50a04b (patch)
tree7ca1dd20806fd71c42f875adc1c653df45b147b1
parent6453a846e788887b6cd74d71c1873a5e3270434d (diff)
downloadjustbuild-dc1db0e8b43f5e907a3ded2e39da8b58fa50a04b.tar.gz
Store HashFunction by const reference.
Despite the fact that HashFunction is a small type, it still makes sense to store it by reference to reflect the ownership. StorageConfig becomes the main holder. Reference holders store HashFunction by const ref and aren't allowed to change it. However, they are free to return HashFunction by value since this doesn't benefit readability anyhow.
-rw-r--r--src/buildtool/execution_api/common/api_bundle.cpp6
-rw-r--r--src/buildtool/execution_api/common/api_bundle.hpp4
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp15
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.hpp2
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network.cpp6
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network.hpp17
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp4
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp9
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp13
-rw-r--r--src/buildtool/file_system/object_cas.hpp6
-rw-r--r--src/buildtool/storage/local_cas.hpp8
-rw-r--r--test/buildtool/execution_api/bazel/bazel_api.test.cpp2
-rw-r--r--test/buildtool/execution_api/bazel/bazel_network.test.cpp4
-rw-r--r--test/buildtool/execution_engine/executor/executor.test.cpp18
-rw-r--r--test/buildtool/execution_engine/executor/executor_api.test.hpp16
-rw-r--r--test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp10
-rw-r--r--test/buildtool/file_system/object_cas.test.cpp4
-rw-r--r--test/utils/executor/test_api_bundle.hpp4
18 files changed, 75 insertions, 73 deletions
diff --git a/src/buildtool/execution_api/common/api_bundle.cpp b/src/buildtool/execution_api/common/api_bundle.cpp
index 8808e5d8..2106f555 100644
--- a/src/buildtool/execution_api/common/api_bundle.cpp
+++ b/src/buildtool/execution_api/common/api_bundle.cpp
@@ -24,7 +24,7 @@ auto ApiBundle::Create(
gsl::not_null<LocalContext const*> const& local_context,
gsl::not_null<RemoteContext const*> const& remote_context,
RepositoryConfig const* repo_config) -> ApiBundle {
- auto const hash_fct = local_context->storage_config->hash_function;
+ auto const& hash_fct = local_context->storage_config->hash_function;
IExecutionApi::Ptr local_api =
std::make_shared<LocalApi>(local_context, repo_config);
IExecutionApi::Ptr remote_api = local_api;
@@ -37,7 +37,7 @@ auto ApiBundle::Create(
remote_context->auth,
remote_context->retry_config,
config,
- hash_fct);
+ &hash_fct);
}
return ApiBundle{.hash_function = hash_fct,
.local = std::move(local_api),
@@ -58,7 +58,7 @@ auto ApiBundle::MakeRemote(
authentication,
retry_config,
config,
- hash_function);
+ &hash_function);
}
return local;
}
diff --git a/src/buildtool/execution_api/common/api_bundle.hpp b/src/buildtool/execution_api/common/api_bundle.hpp
index 28595010..e342ce55 100644
--- a/src/buildtool/execution_api/common/api_bundle.hpp
+++ b/src/buildtool/execution_api/common/api_bundle.hpp
@@ -49,9 +49,7 @@ struct ApiBundle final {
gsl::not_null<RetryConfig const*> const& retry_config) const
-> gsl::not_null<IExecutionApi::Ptr>;
- HashFunction const hash_function;
- // 7 bytes of alignment.
-
+ HashFunction const& hash_function;
gsl::not_null<IExecutionApi::Ptr> const local;
gsl::not_null<IExecutionApi::Ptr> const remote;
};
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index e42c32e7..c5d77194 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -184,13 +184,14 @@ namespace {
} // namespace
-BazelApi::BazelApi(std::string const& instance_name,
- std::string const& host,
- Port port,
- gsl::not_null<Auth const*> const& auth,
- gsl::not_null<RetryConfig const*> const& retry_config,
- ExecutionConfiguration const& exec_config,
- HashFunction hash_function) noexcept {
+BazelApi::BazelApi(
+ std::string const& instance_name,
+ std::string const& host,
+ Port port,
+ gsl::not_null<Auth const*> const& auth,
+ gsl::not_null<RetryConfig const*> const& retry_config,
+ ExecutionConfiguration const& exec_config,
+ gsl::not_null<HashFunction const*> const& hash_function) noexcept {
network_ = std::make_shared<BazelNetwork>(instance_name,
host,
port,
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
index 6b2a6f17..b829529c 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.hpp
@@ -48,7 +48,7 @@ class BazelApi final : public IExecutionApi {
gsl::not_null<Auth const*> const& auth,
gsl::not_null<RetryConfig const*> const& retry_config,
ExecutionConfiguration const& exec_config,
- HashFunction hash_function) noexcept;
+ gsl::not_null<HashFunction const*> const& hash_function) noexcept;
BazelApi(BazelApi const&) = delete;
BazelApi(BazelApi&& other) noexcept;
auto operator=(BazelApi const&) -> BazelApi& = delete;
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
index edf18249..6cb7e905 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network.cpp
@@ -28,7 +28,7 @@ BazelNetwork::BazelNetwork(
gsl::not_null<Auth const*> const& auth,
gsl::not_null<RetryConfig const*> const& retry_config,
ExecutionConfiguration const& exec_config,
- HashFunction hash_function) noexcept
+ gsl::not_null<HashFunction const*> const& hash_function) noexcept
: instance_name_{std::move(instance_name)},
cas_{std::make_unique<BazelCasClient>(host, port, auth, retry_config)},
ac_{std::make_unique<BazelAcClient>(host, port, auth, retry_config)},
@@ -37,7 +37,7 @@ BazelNetwork::BazelNetwork(
auth,
retry_config)},
exec_config_{exec_config},
- hash_function_{hash_function} {}
+ hash_function_{*hash_function} {}
auto BazelNetwork::IsAvailable(bazel_re::Digest const& digest) const noexcept
-> bool {
@@ -144,7 +144,7 @@ auto BazelNetwork::ExecuteBazelActionSync(
}
auto BazelNetwork::CreateReader() const noexcept -> BazelNetworkReader {
- return BazelNetworkReader{instance_name_, cas_.get(), hash_function_};
+ return BazelNetworkReader{instance_name_, cas_.get(), &hash_function_};
}
auto BazelNetwork::GetCachedActionResult(
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp
index 645b403d..a744daaf 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network.hpp
@@ -39,13 +39,14 @@
/// \brief Contains all network clients and is responsible for all network IO.
class BazelNetwork {
public:
- explicit BazelNetwork(std::string instance_name,
- std::string const& host,
- Port port,
- gsl::not_null<Auth const*> const& auth,
- gsl::not_null<RetryConfig const*> const& retry_config,
- ExecutionConfiguration const& exec_config,
- HashFunction hash_function) noexcept;
+ explicit BazelNetwork(
+ std::string instance_name,
+ std::string const& host,
+ Port port,
+ gsl::not_null<Auth const*> const& auth,
+ gsl::not_null<RetryConfig const*> const& retry_config,
+ ExecutionConfiguration const& exec_config,
+ gsl::not_null<HashFunction const*> const& hash_function) noexcept;
/// \brief Check if digest exists in CAS
/// \param[in] digest The digest to look up
@@ -96,7 +97,7 @@ class BazelNetwork {
std::unique_ptr<BazelAcClient> ac_{};
std::unique_ptr<BazelExecutionClient> exec_{};
ExecutionConfiguration exec_config_{};
- HashFunction const hash_function_;
+ HashFunction const& hash_function_;
template <class T_Iter>
[[nodiscard]] auto DoUploadBlobs(T_Iter const& first,
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
index 5dac053b..d5f2f3f8 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.cpp
@@ -30,10 +30,10 @@
BazelNetworkReader::BazelNetworkReader(
std::string instance_name,
gsl::not_null<BazelCasClient const*> const& cas,
- HashFunction hash_function) noexcept
+ gsl::not_null<HashFunction const*> const& hash_function) noexcept
: instance_name_{std::move(instance_name)},
cas_{*cas},
- hash_function_{hash_function} {}
+ hash_function_{*hash_function} {}
BazelNetworkReader::BazelNetworkReader(
BazelNetworkReader&& other,
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp
index 5c6cdbf9..e3e283c7 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_network_reader.hpp
@@ -41,9 +41,10 @@ class BazelNetworkReader final {
public:
using DumpCallback = std::function<bool(std::string const&)>;
- explicit BazelNetworkReader(std::string instance_name,
- gsl::not_null<BazelCasClient const*> const& cas,
- HashFunction hash_function) noexcept;
+ explicit BazelNetworkReader(
+ std::string instance_name,
+ gsl::not_null<BazelCasClient const*> const& cas,
+ gsl::not_null<HashFunction const*> const& hash_function) noexcept;
BazelNetworkReader(
BazelNetworkReader&& other,
@@ -84,7 +85,7 @@ class BazelNetworkReader final {
std::string const instance_name_;
BazelCasClient const& cas_;
- HashFunction const hash_function_;
+ HashFunction const& hash_function_;
std::optional<DirectoryMap> auxiliary_map_;
[[nodiscard]] auto MakeAuxiliaryMap(
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index c9914ab6..9428a6e4 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -64,7 +64,7 @@ class ExecutorImpl {
IExecutionApi const& api,
ExecutionProperties const& merged_properties,
gsl::not_null<RemoteContext const*> const& remote_context,
- HashFunction hash_function,
+ gsl::not_null<HashFunction const*> const& hash_function,
std::chrono::milliseconds const& timeout,
IExecutionAction::CacheFlag cache_flag,
gsl::not_null<Statistics*> const& stats,
@@ -717,7 +717,8 @@ class ExecutorImpl {
[[nodiscard]] static inline auto GetAlternativeEndpoint(
const ExecutionProperties& properties,
const gsl::not_null<RemoteContext const*>& remote_context,
- HashFunction hash_function) -> std::unique_ptr<BazelApi> {
+ const gsl::not_null<HashFunction const*>& hash_function)
+ -> std::unique_ptr<BazelApi> {
for (auto const& [pred, endpoint] :
remote_context->exec_config->dispatch) {
bool match = true;
@@ -783,7 +784,7 @@ class Executor {
context_.remote_context->exec_config->platform_properties,
action->ExecutionProperties()),
context_.remote_context,
- context_.apis->hash_function,
+ &context_.apis->hash_function,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput,
context_.statistics,
@@ -806,7 +807,7 @@ class Executor {
context_.remote_context->exec_config->platform_properties,
action->ExecutionProperties()),
context_.remote_context,
- context_.apis->hash_function,
+ &context_.apis->hash_function,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
action->NoCache() ? CF::DoNotCacheOutput : CF::CacheOutput,
context_.statistics,
@@ -880,7 +881,7 @@ class Rebuilder {
context_.remote_context->exec_config->platform_properties,
action->ExecutionProperties()),
context_.remote_context,
- context_.apis->hash_function,
+ &context_.apis->hash_function,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
CF::PretendCached,
context_.statistics,
@@ -899,7 +900,7 @@ class Rebuilder {
context_.remote_context->exec_config->platform_properties,
action->ExecutionProperties()),
context_.remote_context,
- context_.apis->hash_function,
+ &context_.apis->hash_function,
Impl::ScaleTime(timeout_, action->TimeoutScale()),
CF::FromCacheOnly,
context_.statistics,
diff --git a/src/buildtool/file_system/object_cas.hpp b/src/buildtool/file_system/object_cas.hpp
index edf43854..2616814c 100644
--- a/src/buildtool/file_system/object_cas.hpp
+++ b/src/buildtool/file_system/object_cas.hpp
@@ -53,13 +53,13 @@ class ObjectCAS {
/// \param store_path The path to use for storing blobs.
/// \param exists (optional) Function for checking blob existence.
explicit ObjectCAS(
- HashFunction hash_function,
+ gsl::not_null<HashFunction const*> const& hash_function,
std::filesystem::path const& store_path,
std::optional<gsl::not_null<ExistsFunc>> exists = std::nullopt)
: file_store_{store_path},
exists_{exists.has_value() ? std::move(exists)->get()
: kDefaultExists},
- hash_function_{hash_function} {}
+ hash_function_{*hash_function} {}
ObjectCAS(ObjectCAS const&) = delete;
ObjectCAS(ObjectCAS&&) = delete;
@@ -115,7 +115,7 @@ class ObjectCAS {
FileStorage<kStorageType, StoreMode::FirstWins, /*kSetEpochTime=*/true>
file_store_;
gsl::not_null<ExistsFunc> exists_;
- HashFunction const hash_function_;
+ HashFunction const& hash_function_;
/// Default callback for checking blob existence.
static inline ExistsFunc const kDefaultExists = [](auto const& /*digest*/,
diff --git a/src/buildtool/storage/local_cas.hpp b/src/buildtool/storage/local_cas.hpp
index 8a95c234..8c8d70c2 100644
--- a/src/buildtool/storage/local_cas.hpp
+++ b/src/buildtool/storage/local_cas.hpp
@@ -52,13 +52,13 @@ class LocalCAS {
explicit LocalCAS(
GenerationConfig const& config,
gsl::not_null<Uplinker<kDoGlobalUplink> const*> const& uplinker)
- : cas_file_{config.storage_config->hash_function,
+ : cas_file_{&config.storage_config->hash_function,
config.cas_f,
MakeUplinker<ObjectType::File>(config, uplinker)},
- cas_exec_{config.storage_config->hash_function,
+ cas_exec_{&config.storage_config->hash_function,
config.cas_x,
MakeUplinker<ObjectType::Executable>(config, uplinker)},
- cas_tree_{config.storage_config->hash_function,
+ cas_tree_{&config.storage_config->hash_function,
config.cas_t,
MakeUplinker<ObjectType::Tree>(config, uplinker)},
cas_file_large_{this, config, uplinker},
@@ -284,7 +284,7 @@ class LocalCAS {
ObjectCAS<ObjectType::Tree> cas_tree_;
LargeObjectCAS<kDoGlobalUplink, ObjectType::File> cas_file_large_;
LargeObjectCAS<kDoGlobalUplink, ObjectType::Tree> cas_tree_large_;
- HashFunction const hash_function_;
+ HashFunction const& hash_function_;
/// \brief Provides uplink via "exists callback" for physical object CAS.
template <ObjectType kType>
diff --git a/test/buildtool/execution_api/bazel/bazel_api.test.cpp b/test/buildtool/execution_api/bazel/bazel_api.test.cpp
index 16c45aae..e201111c 100644
--- a/test/buildtool/execution_api/bazel/bazel_api.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_api.test.cpp
@@ -46,7 +46,7 @@ class FactoryApi final {
&auth_,
&retry_config,
{},
- hash_function_}};
+ &hash_function_}};
}
private:
diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
index 8224de74..e5dab868 100644
--- a/test/buildtool/execution_api/bazel/bazel_network.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
@@ -55,7 +55,7 @@ TEST_CASE("Bazel network: write/read blobs", "[execution_api]") {
&*auth_config,
&retry_config,
{},
- hash_function};
+ &hash_function};
std::string content_foo("foo");
std::string content_bar("bar");
@@ -119,7 +119,7 @@ TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") {
&*auth_config,
&retry_config,
{},
- hash_function};
+ &hash_function};
std::string content_foo("foo");
std::string content_bar(kLargeSize, 'x'); // single larger blob
diff --git a/test/buildtool/execution_engine/executor/executor.test.cpp b/test/buildtool/execution_engine/executor/executor.test.cpp
index e2d62342..46ad743e 100644
--- a/test/buildtool/execution_engine/executor/executor.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor.test.cpp
@@ -325,7 +325,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -343,7 +343,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -361,7 +361,7 @@ TEST_CASE("Executor: Process artifact", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -408,7 +408,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -429,7 +429,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -450,7 +450,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -474,7 +474,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -495,7 +495,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
@@ -519,7 +519,7 @@ TEST_CASE("Executor: Process action", "[executor]") {
auto api = TestApi::Ptr{new TestApi{config}};
Statistics stats{};
Progress progress{};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = &repo_config,
.apis = &apis,
.remote_context = &remote_context,
diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp
index c323bde6..82643576 100644
--- a/test/buildtool/execution_engine/executor/executor_api.test.hpp
+++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp
@@ -145,7 +145,7 @@ static inline void RunHelloWorldCompilation(
HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = repo_config,
.apis = &apis,
@@ -278,7 +278,7 @@ static inline void RunGreeterCompilation(
HashFunction const hash_function{TestHashType::ReadFromEnvironment()};
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = repo_config,
.apis = &apis,
@@ -447,7 +447,7 @@ static inline void TestUploadAndDownloadTrees(
.retry_config = &retry_config,
.exec_config = &*remote_config};
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = repo_config,
.apis = &apis,
@@ -621,7 +621,7 @@ static inline void TestRetrieveOutputDirectories(
// run action
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = repo_config,
.apis = &apis,
@@ -675,7 +675,7 @@ static inline void TestRetrieveOutputDirectories(
// run action
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = repo_config,
.apis = &apis,
@@ -746,7 +746,7 @@ static inline void TestRetrieveOutputDirectories(
// run action
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{.repo_config = repo_config,
.apis = &apis,
@@ -819,7 +819,7 @@ static inline void TestRetrieveOutputDirectories(
// run action
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{
.repo_config = repo_config,
@@ -846,7 +846,7 @@ static inline void TestRetrieveOutputDirectories(
// run action
auto api = factory();
- auto const apis = CreateTestApiBundle(hash_function, api);
+ auto const apis = CreateTestApiBundle(&hash_function, api);
ExecutionContext const exec_context{
.repo_config = repo_config,
diff --git a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
index f024941c..7fc5018f 100644
--- a/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
+++ b/test/buildtool/execution_engine/executor/executor_api_remote_bazel.test.cpp
@@ -50,7 +50,7 @@ TEST_CASE("Executor<BazelApi>: Upload blob", "[executor]") {
&*auth_config,
&retry_config,
config,
- hash_function}};
+ &hash_function}};
});
}
@@ -84,7 +84,7 @@ TEST_CASE("Executor<BazelApi>: Compile hello world", "[executor]") {
&*auth_config,
&retry_config,
config,
- hash_function}};
+ &hash_function}};
},
&*auth_config,
false /* not hermetic */);
@@ -120,7 +120,7 @@ TEST_CASE("Executor<BazelApi>: Compile greeter", "[executor]") {
&*auth_config,
&retry_config,
config,
- hash_function}};
+ &hash_function}};
},
&*auth_config,
false /* not hermetic */);
@@ -156,7 +156,7 @@ TEST_CASE("Executor<BazelApi>: Upload and download trees", "[executor]") {
&*auth_config,
&retry_config,
config,
- hash_function}};
+ &hash_function}};
},
&*auth_config,
false /* not hermetic */);
@@ -192,7 +192,7 @@ TEST_CASE("Executor<BazelApi>: Retrieve output directories", "[executor]") {
&*auth_config,
&retry_config,
config,
- hash_function}};
+ &hash_function}};
},
&*auth_config,
false /* not hermetic */);
diff --git a/test/buildtool/file_system/object_cas.test.cpp b/test/buildtool/file_system/object_cas.test.cpp
index 6f06eea4..1872f25b 100644
--- a/test/buildtool/file_system/object_cas.test.cpp
+++ b/test/buildtool/file_system/object_cas.test.cpp
@@ -34,7 +34,7 @@ TEST_CASE("ObjectCAS", "[file_system]") {
storage_config.Get().hash_function, test_content);
SECTION("CAS for files") {
- ObjectCAS<ObjectType::File> cas{storage_config.Get().hash_function,
+ ObjectCAS<ObjectType::File> cas{&storage_config.Get().hash_function,
gen_config.cas_f};
CHECK(not cas.BlobPath(test_digest));
@@ -74,7 +74,7 @@ TEST_CASE("ObjectCAS", "[file_system]") {
SECTION("CAS for executables") {
ObjectCAS<ObjectType::Executable> cas{
- storage_config.Get().hash_function, gen_config.cas_x};
+ &storage_config.Get().hash_function, gen_config.cas_x};
CHECK(not cas.BlobPath(test_digest));
SECTION("Add blob from bytes and verify") {
diff --git a/test/utils/executor/test_api_bundle.hpp b/test/utils/executor/test_api_bundle.hpp
index 1b582ce6..088c4323 100644
--- a/test/utils/executor/test_api_bundle.hpp
+++ b/test/utils/executor/test_api_bundle.hpp
@@ -26,10 +26,10 @@
/// implementation. As only the hash_function field is actually needed, the
/// remote_context and repo_config are not needed to be provided.
[[nodiscard]] static auto CreateTestApiBundle(
- HashFunction hash_function,
+ gsl::not_null<HashFunction const*> const& hash_function,
gsl::not_null<IExecutionApi::Ptr> const& api) noexcept -> ApiBundle {
return ApiBundle{
- .hash_function = hash_function, .local = api, .remote = api};
+ .hash_function = *hash_function, .local = api, .remote = api};
}
#endif // INCLUDED_SRC_TEST_UTILS_EXECUTOR_TEST_API_BUNDLE_HPP