summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-01 10:26:13 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-01 19:00:47 +0200
commit03f948f4b10e916052a2234448b6658b80ee9143 (patch)
tree8eb0e2c26a31fd83fa0691b0d8fde55a15942a9d /test/buildtool/execution_api
parented71beee3e3a2bbfcba24281ad9e28a0f6df4054 (diff)
downloadjustbuild-03f948f4b10e916052a2234448b6658b80ee9143.tar.gz
Execution API: support cwd
... following the remote-execution standard that all output paths (but none of the input paths) are relative to the working directory. Therefore, the executor has to do the path translation. For our implementation of the API interface - the local API now handles cwd correctly, - the remote API forwards cwd correctly, and - the git API continues to report actions as not implemented.
Diffstat (limited to 'test/buildtool/execution_api')
-rw-r--r--test/buildtool/execution_api/common/api_test.hpp16
-rw-r--r--test/buildtool/execution_api/local/local_execution.test.cpp8
2 files changed, 19 insertions, 5 deletions
diff --git a/test/buildtool/execution_api/common/api_test.hpp b/test/buildtool/execution_api/common/api_test.hpp
index 6d8e7928..54394b62 100644
--- a/test/buildtool/execution_api/common/api_test.hpp
+++ b/test/buildtool/execution_api/common/api_test.hpp
@@ -70,8 +70,13 @@ using ExecProps = std::map<std::string, std::string>;
auto api = api_factory();
- auto action = api->CreateAction(
- *api->UploadTree({}), {"echo", "-n", test_content}, {}, {}, {}, props);
+ auto action = api->CreateAction(*api->UploadTree({}),
+ {"echo", "-n", test_content},
+ "",
+ {},
+ {},
+ {},
+ props);
SECTION("Cache execution result in action cache") {
action->SetCacheFlag(IExecutionAction::CacheFlag::CacheOutput);
@@ -147,6 +152,7 @@ using ExecProps = std::map<std::string, std::string>;
{"/bin/sh",
"-c",
"set -e\necho -n " + test_content + " > " + output_path},
+ "",
{output_path},
{},
{},
@@ -238,6 +244,7 @@ using ExecProps = std::map<std::string, std::string>;
auto action =
api->CreateAction(*api->UploadTree({{input_path, &input_artifact}}),
{"cp", input_path, output_path},
+ "",
{output_path},
{},
{},
@@ -320,6 +327,7 @@ using ExecProps = std::map<std::string, std::string>;
"-c",
"set -e\necho -n " + test_content + " > " +
output_path + "\nexit 1\n"},
+ "",
{output_path},
{},
{},
@@ -412,6 +420,7 @@ using ExecProps = std::map<std::string, std::string>;
auto action = api->CreateAction(*api->UploadTree({}),
{"/bin/sh", "-c", make_cmd("root")},
+ "",
{},
{"root"},
env,
@@ -484,6 +493,7 @@ TestRetrieveFileAndSymlinkWithSameContentToPath(ApiFactory const& api_factory,
auto action = api->CreateAction(*api->UploadTree({}),
{"/bin/sh", "-c", make_cmd("root")},
+ "",
{},
{"root"},
env,
@@ -552,6 +562,7 @@ TestRetrieveFileAndSymlinkWithSameContentToPath(ApiFactory const& api_factory,
auto action = api->CreateAction(*api->UploadTree({}),
{"/bin/sh", "-c", cmd},
+ "",
{foo_path.string(), link_path.string()},
{bar_path.parent_path().string()},
env,
@@ -619,6 +630,7 @@ TestRetrieveFileAndSymlinkWithSameContentToPath(ApiFactory const& api_factory,
{"/bin/sh",
"-c",
fmt::format("set -e\n [ -d {} ]", output_path.string())},
+ "",
{},
{output_path},
{},
diff --git a/test/buildtool/execution_api/local/local_execution.test.cpp b/test/buildtool/execution_api/local/local_execution.test.cpp
index a08f3b87..49141076 100644
--- a/test/buildtool/execution_api/local/local_execution.test.cpp
+++ b/test/buildtool/execution_api/local/local_execution.test.cpp
@@ -79,7 +79,7 @@ TEST_CASE("LocalExecution: No input, no output", "[execution_api]") {
std::string test_content("test");
std::vector<std::string> const cmdline = {"echo", "-n", test_content};
auto action =
- api.CreateAction(*api.UploadTree({}), cmdline, {}, {}, {}, {});
+ api.CreateAction(*api.UploadTree({}), cmdline, "", {}, {}, {}, {});
REQUIRE(action);
SECTION("Cache execution result in action cache") {
@@ -134,6 +134,7 @@ TEST_CASE("LocalExecution: No input, no output, env variables used",
"/bin/sh", "-c", "set -e\necho -n ${MYCONTENT}"};
auto action = api.CreateAction(*api.UploadTree({}),
cmdline,
+ "",
{},
{},
{{"MYCONTENT", test_content}},
@@ -198,7 +199,7 @@ TEST_CASE("LocalExecution: No input, create output", "[execution_api]") {
"set -e\necho -n " + test_content + " > " + output_path};
auto action = api.CreateAction(
- *api.UploadTree({}), cmdline, {output_path}, {}, {}, {});
+ *api.UploadTree({}), cmdline, "", {output_path}, {}, {}, {});
REQUIRE(action);
SECTION("Cache execution result in action cache") {
@@ -273,6 +274,7 @@ TEST_CASE("LocalExecution: One input copied to output", "[execution_api]") {
auto action =
api.CreateAction(*api.UploadTree({{input_path, &local_artifact}}),
cmdline,
+ "",
{output_path},
{},
{},
@@ -335,7 +337,7 @@ TEST_CASE("LocalExecution: Cache failed action's result", "[execution_api]") {
"sh", "-c", fmt::format("[ -f '{}' ]", flag.string())};
auto action =
- api.CreateAction(*api.UploadTree({}), cmdline, {}, {}, {}, {});
+ api.CreateAction(*api.UploadTree({}), cmdline, "", {}, {}, {}, {});
REQUIRE(action);
action->SetCacheFlag(IExecutionAction::CacheFlag::CacheOutput);