summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/common/api_test.hpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-13 16:11:34 +0100
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-02-13 17:33:02 +0100
commit90baaac7d69d5fd21471b32b0285bd9b562a5137 (patch)
tree40f65043c1b470f1e751928d725de470b0363641 /test/buildtool/execution_api/common/api_test.hpp
parent16af967b70edd686882a083164c0bc41cd6591a8 (diff)
downloadjustbuild-90baaac7d69d5fd21471b32b0285bd9b562a5137.tar.gz
execution-api test: also set the launcher
... in order to not assume echo to be on the standard search path pulled in by env.
Diffstat (limited to 'test/buildtool/execution_api/common/api_test.hpp')
-rw-r--r--test/buildtool/execution_api/common/api_test.hpp18
1 files changed, 18 insertions, 0 deletions
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<IExecutionApi::Ptr()>;
using ExecProps = std::map<std::string, std::string>;
+inline void SetLauncher() {
+ std::vector<std::string> 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<std::string, std::string>;
auto action = api->CreateAction(
*api->UploadTree({}), {"echo", "-n", test_content}, {}, {}, {}, props);
+ SetLauncher();
+
SECTION("Cache execution result in action cache") {
action->SetCacheFlag(IExecutionAction::CacheFlag::CacheOutput);