From 90baaac7d69d5fd21471b32b0285bd9b562a5137 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 13 Feb 2024 16:11:34 +0100 Subject: execution-api test: also set the launcher ... in order to not assume echo to be on the standard search path pulled in by env. --- test/buildtool/execution_api/common/api_test.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (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 2ac6ee10..be9abb1f 100644 --- a/test/buildtool/execution_api/common/api_test.hpp +++ b/test/buildtool/execution_api/common/api_test.hpp @@ -20,11 +20,27 @@ #include "src/buildtool/execution_api/common/execution_action.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" #include "src/buildtool/execution_api/common/execution_response.hpp" +#include "src/buildtool/execution_api/local/config.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" using ApiFactory = std::function; using ExecProps = std::map; +inline void SetLauncher() { + std::vector launcher{"env"}; + auto* env_path = std::getenv("PATH"); + if (env_path != nullptr) { + launcher.emplace_back(std::string{"PATH="} + std::string{env_path}); + } + 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); + } +} + [[nodiscard]] static inline auto GetTestDir(std::string const& test_name) -> std::filesystem::path { auto* tmp_dir = std::getenv("TEST_TMPDIR"); @@ -46,6 +62,8 @@ using ExecProps = std::map; 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