diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-18 17:51:41 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-23 10:54:50 +0200 |
commit | dc1db0e8b43f5e907a3ded2e39da8b58fa50a04b (patch) | |
tree | 7ca1dd20806fd71c42f875adc1c653df45b147b1 /test | |
parent | 6453a846e788887b6cd74d71c1873a5e3270434d (diff) | |
download | justbuild-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.
Diffstat (limited to 'test')
7 files changed, 29 insertions, 29 deletions
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 |