From eb8d824360ce262502c5fc06072ebf07ea278bec Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 5 Jul 2024 17:18:19 +0200 Subject: Pass LocalExecutionConfig to LocalAction and LocalApi --- .../execution_api/local/local_api.test.cpp | 37 +++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'test/buildtool/execution_api/local/local_api.test.cpp') diff --git a/test/buildtool/execution_api/local/local_api.test.cpp b/test/buildtool/execution_api/local/local_api.test.cpp index a2fee207..164226b9 100644 --- a/test/buildtool/execution_api/local/local_api.test.cpp +++ b/test/buildtool/execution_api/local/local_api.test.cpp @@ -16,6 +16,7 @@ #include #include "catch2/catch_test_macros.hpp" +#include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/execution_api/local/local_api.hpp" #include "src/buildtool/storage/config.hpp" #include "src/buildtool/storage/storage.hpp" @@ -27,16 +28,22 @@ class FactoryApi final { public: explicit FactoryApi( gsl::not_null const& storage_config, - gsl::not_null const& storage) noexcept - : storage_config_{*storage_config}, storage_{*storage} {} + gsl::not_null const& storage, + gsl::not_null const& + local_exec_config) noexcept + : storage_config_{*storage_config}, + storage_{*storage}, + local_exec_config_{*local_exec_config} {} [[nodiscard]] auto operator()() const -> IExecutionApi::Ptr { - return IExecutionApi::Ptr{new LocalApi{&storage_config_, &storage_}}; + return IExecutionApi::Ptr{ + new LocalApi{&storage_config_, &storage_, &local_exec_config_}}; } private: StorageConfig const& storage_config_; Storage const& storage_; + LocalExecutionConfig const& local_exec_config_; }; } // namespace @@ -44,7 +51,8 @@ class FactoryApi final { TEST_CASE("LocalAPI: No input, no output", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestNoInputNoOutput(api_factory, {}, /*is_hermetic=*/true); } @@ -52,7 +60,8 @@ TEST_CASE("LocalAPI: No input, no output", "[execution_api]") { TEST_CASE("LocalAPI: No input, create output", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestNoInputCreateOutput(api_factory, {}, /*is_hermetic=*/true); } @@ -60,7 +69,8 @@ TEST_CASE("LocalAPI: No input, create output", "[execution_api]") { TEST_CASE("LocalAPI: One input copied to output", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestOneInputCopiedToOutput(api_factory, {}, /*is_hermetic=*/true); } @@ -68,7 +78,8 @@ TEST_CASE("LocalAPI: One input copied to output", "[execution_api]") { TEST_CASE("LocalAPI: Non-zero exit code, create output", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestNonZeroExitCodeCreateOutput(api_factory, {}); } @@ -76,7 +87,8 @@ TEST_CASE("LocalAPI: Non-zero exit code, create output", "[execution_api]") { TEST_CASE("LocalAPI: Retrieve two identical trees to path", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestRetrieveTwoIdenticalTreesToPath( api_factory, {}, "two_trees", /*is_hermetic=*/true); @@ -86,7 +98,8 @@ TEST_CASE("LocalAPI: Retrieve file and symlink with same content to path", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestRetrieveFileAndSymlinkWithSameContentToPath( api_factory, {}, "file_and_symlink", /*is_hermetic=*/true); @@ -95,7 +108,8 @@ TEST_CASE("LocalAPI: Retrieve file and symlink with same content to path", TEST_CASE("LocalAPI: Retrieve mixed blobs and trees", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestRetrieveMixedBlobsAndTrees( api_factory, {}, "blobs_and_trees", /*is_hermetic=*/true); @@ -104,7 +118,8 @@ TEST_CASE("LocalAPI: Retrieve mixed blobs and trees", "[execution_api]") { TEST_CASE("LocalAPI: Create directory prior to execution", "[execution_api]") { auto const storage_config = TestStorageConfig::Create(); auto const storage = Storage::Create(&storage_config.Get()); - FactoryApi api_factory(&storage_config.Get(), &storage); + FactoryApi api_factory( + &storage_config.Get(), &storage, &LocalExecutionConfig::Instance()); TestCreateDirPriorToExecution(api_factory, {}, /*is_hermetic=*/true); } -- cgit v1.2.3