From 978de9de55d9592c258052dd52dc25c788a89d78 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 8 Jul 2024 11:28:13 +0200 Subject: Remove the LocalExecutionConfig singleton ...and replace it with passed instances created early via a builder pattern. --- test/buildtool/execution_api/common/api_test.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test/buildtool/execution_api/common/api_test.hpp') diff --git a/test/buildtool/execution_api/common/api_test.hpp b/test/buildtool/execution_api/common/api_test.hpp index d43c850d..f9a814f7 100644 --- a/test/buildtool/execution_api/common/api_test.hpp +++ b/test/buildtool/execution_api/common/api_test.hpp @@ -32,7 +32,8 @@ using ApiFactory = std::function; using ExecProps = std::map; -inline void SetLauncher() { +[[nodiscard]] static inline auto SetLauncher() noexcept + -> LocalExecutionConfig { std::vector launcher{"env"}; auto* env_path = std::getenv("PATH"); if (env_path != nullptr) { @@ -41,10 +42,12 @@ inline void SetLauncher() { else { launcher.emplace_back("PATH=/bin:/usr/bin"); } - if (not LocalExecutionConfig::SetLauncher(launcher)) { - Logger::Log(LogLevel::Error, "Failure setting the local launcher."); - std::exit(EXIT_FAILURE); + LocalExecutionConfig::Builder builder; + if (auto config = builder.SetLauncher(std::move(launcher)).Build()) { + return *std::move(config); } + Logger::Log(LogLevel::Error, "Failure setting the local launcher."); + std::exit(EXIT_FAILURE); } [[nodiscard]] static inline auto GetTestDir(std::string const& test_name) @@ -68,8 +71,6 @@ inline void SetLauncher() { auto action = api->CreateAction( *api->UploadTree({}), {"echo", "-n", test_content}, {}, {}, {}, props); - SetLauncher(); - SECTION("Cache execution result in action cache") { action->SetCacheFlag(IExecutionAction::CacheFlag::CacheOutput); -- cgit v1.2.3