diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2025-05-09 14:55:05 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2025-05-19 12:33:06 +0200 |
commit | c1340f6124f288cad8f800c94e5ff34259244b60 (patch) | |
tree | c19aafdfe5e216e50026f2ee360c24c05fe130c8 /test/buildtool/execution_api/common/api_test.hpp | |
parent | 350182400feccc99aba9fbf290d6f7249adb3a21 (diff) | |
download | justbuild-c1340f6124f288cad8f800c94e5ff34259244b60.tar.gz |
LocalAction: Fix collection of directory symlink
(cherry-picked from fe4006fce755432b1ae3a273873f3649512c7f94)
Diffstat (limited to 'test/buildtool/execution_api/common/api_test.hpp')
-rw-r--r-- | test/buildtool/execution_api/common/api_test.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/buildtool/execution_api/common/api_test.hpp b/test/buildtool/execution_api/common/api_test.hpp index f8981434..441c27b0 100644 --- a/test/buildtool/execution_api/common/api_test.hpp +++ b/test/buildtool/execution_api/common/api_test.hpp @@ -725,4 +725,36 @@ TestRetrieveFileAndSymlinkWithSameContentToPath(ApiFactory const& api_factory, } } +[[nodiscard]] static inline auto TestSymlinkCollection( + ApiFactory const& api_factory, + ExecProps const& props) { + auto api = api_factory(); + + auto action = api->CreateAction( + *api->UploadTree({}), + {"/bin/sh", "-c", "set -e; ln -s none foo; rm -rf bar; ln -s none bar"}, + "", + {"foo"}, + {"bar"}, + {}, + props); + + // run execution + auto const response = action->Execute(); + REQUIRE(response); + + // verify result + auto const artifacts = response->Artifacts(); + REQUIRE(artifacts.has_value()); + REQUIRE(artifacts.value()->contains("foo")); + CHECK(IsSymlinkObject(artifacts.value()->at("foo").type)); + REQUIRE(artifacts.value()->contains("bar")); + CHECK(IsSymlinkObject(artifacts.value()->at("bar").type)); + + // check if bar was correctly detected as directory symlink + auto dir_symlinks = response->DirectorySymlinks(); + REQUIRE(dir_symlinks); + CHECK((*dir_symlinks)->contains("bar")); +} + #endif // INCLUDED_SRC_TEST_BUILDTOOL_EXECUTION_API_COMMON_API_TEST_HPP |