summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/common/api_test.hpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-08 11:28:13 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-16 17:51:12 +0200
commit978de9de55d9592c258052dd52dc25c788a89d78 (patch)
treedff959d84f1d95af1f0546471d3b2c7eaa47dbc2 /test/buildtool/execution_api/common/api_test.hpp
parentb4cd4d0c0d1b526eab3549c9cba12179dbba3a3f (diff)
downloadjustbuild-978de9de55d9592c258052dd52dc25c788a89d78.tar.gz
Remove the LocalExecutionConfig singleton
...and replace it with passed instances created early via a builder pattern.
Diffstat (limited to 'test/buildtool/execution_api/common/api_test.hpp')
-rw-r--r--test/buildtool/execution_api/common/api_test.hpp13
1 files changed, 7 insertions, 6 deletions
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<IExecutionApi::Ptr()>;
using ExecProps = std::map<std::string, std::string>;
-inline void SetLauncher() {
+[[nodiscard]] static inline auto SetLauncher() noexcept
+ -> LocalExecutionConfig {
std::vector<std::string> 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);