From 62d204ff4cc94c12c1635f189255710901682825 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Fri, 12 Jul 2024 16:09:28 +0200 Subject: Remove the RemoteExecutionConfig singleton ...and replace it with passed instances created early via a builder pattern. Tests are also updated accordingly. --- .../execution_api/bazel/bazel_api.test.cpp | 54 ++++++++++++++-------- 1 file changed, 35 insertions(+), 19 deletions(-) (limited to 'test/buildtool/execution_api/bazel/bazel_api.test.cpp') diff --git a/test/buildtool/execution_api/bazel/bazel_api.test.cpp b/test/buildtool/execution_api/bazel/bazel_api.test.cpp index 8c2d6633..9b9e6def 100644 --- a/test/buildtool/execution_api/bazel/bazel_api.test.cpp +++ b/test/buildtool/execution_api/bazel/bazel_api.test.cpp @@ -20,59 +20,75 @@ #include "src/buildtool/execution_api/remote/config.hpp" #include "test/buildtool/execution_api/common/api_test.hpp" #include "test/utils/remote_execution/test_auth_config.hpp" +#include "test/utils/remote_execution/test_remote_config.hpp" namespace { auto const kApiFactory = []() { - static auto const& server = RemoteExecutionConfig::RemoteAddress(); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + REQUIRE(remote_config->remote_address); auto auth_config = TestAuthConfig::ReadFromEnvironment(); REQUIRE(auth_config); - return IExecutionApi::Ptr{new BazelApi{ - "remote-execution", server->host, server->port, &*auth_config, {}}}; + return IExecutionApi::Ptr{new BazelApi{"remote-execution", + remote_config->remote_address->host, + remote_config->remote_address->port, + &*auth_config, + {}}}; }; } // namespace TEST_CASE("BazelAPI: No input, no output", "[execution_api]") { - TestNoInputNoOutput(kApiFactory, - RemoteExecutionConfig::PlatformProperties()); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + TestNoInputNoOutput(kApiFactory, remote_config->platform_properties); } TEST_CASE("BazelAPI: No input, create output", "[execution_api]") { - TestNoInputCreateOutput(kApiFactory, - RemoteExecutionConfig::PlatformProperties()); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + TestNoInputCreateOutput(kApiFactory, remote_config->platform_properties); } TEST_CASE("BazelAPI: One input copied to output", "[execution_api]") { - TestOneInputCopiedToOutput(kApiFactory, - RemoteExecutionConfig::PlatformProperties()); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + TestOneInputCopiedToOutput(kApiFactory, remote_config->platform_properties); } TEST_CASE("BazelAPI: Non-zero exit code, create output", "[execution_api]") { - TestNonZeroExitCodeCreateOutput( - kApiFactory, RemoteExecutionConfig::PlatformProperties()); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + TestNonZeroExitCodeCreateOutput(kApiFactory, + remote_config->platform_properties); } TEST_CASE("BazelAPI: Retrieve two identical trees to path", "[execution_api]") { + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); TestRetrieveTwoIdenticalTreesToPath( - kApiFactory, RemoteExecutionConfig::PlatformProperties(), "two_trees"); + kApiFactory, remote_config->platform_properties, "two_trees"); } TEST_CASE("BazelAPI: Retrieve file and symlink with same content to path", "[execution_api]") { + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); TestRetrieveFileAndSymlinkWithSameContentToPath( - kApiFactory, - RemoteExecutionConfig::PlatformProperties(), - "file_and_symlink"); + kApiFactory, remote_config->platform_properties, "file_and_symlink"); } TEST_CASE("BazelAPI: Retrieve mixed blobs and trees", "[execution_api]") { - TestRetrieveMixedBlobsAndTrees(kApiFactory, - RemoteExecutionConfig::PlatformProperties(), - "blobs_and_trees"); + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); + TestRetrieveMixedBlobsAndTrees( + kApiFactory, remote_config->platform_properties, "blobs_and_trees"); } TEST_CASE("BazelAPI: Create directory prior to execution", "[execution_api]") { + auto remote_config = TestRemoteConfig::ReadFromEnvironment(); + REQUIRE(remote_config); TestCreateDirPriorToExecution(kApiFactory, - RemoteExecutionConfig::PlatformProperties()); + remote_config->platform_properties); } -- cgit v1.2.3