From 629dc072c7c81693e55cafaa90e63ff1128b0efe Mon Sep 17 00:00:00 2001 From: Alberto Sartori Date: Fri, 21 Jul 2023 11:26:52 +0200 Subject: bugfix: stage symlinks as symlinks when creating an action directory Before this patch, when creating an action directory, symlinks were staged as regular files. --- .../executor/executor_api.test.hpp | 6 +-- test/end-to-end/TARGETS | 1 + test/end-to-end/symlinks/TARGETS | 8 ++++ test/end-to-end/symlinks/stage-links.sh | 55 ++++++++++++++++++++++ 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 test/end-to-end/symlinks/TARGETS create mode 100644 test/end-to-end/symlinks/stage-links.sh (limited to 'test') diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp index 30d724ea..ffee5184 100755 --- a/test/buildtool/execution_engine/executor/executor_api.test.hpp +++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp @@ -398,11 +398,9 @@ static inline void TestUploadAndDownloadTrees(ApiFactory const& factory, CHECK(FileSystemManager::IsDirectory(tmpdir)); CHECK(FileSystemManager::IsDirectory(tmpdir / "b")); CHECK(FileSystemManager::IsFile(tmpdir / "a")); - // echo command returns regular file instead of symlink - CHECK(FileSystemManager::IsFile(tmpdir / "b" / "a")); + CHECK(FileSystemManager::IsNonUpwardsSymlink(tmpdir / "b" / "a")); CHECK(*FileSystemManager::ReadFile(tmpdir / "a") == "foo"); - // echo command returns regular file instead of symlink - CHECK(*FileSystemManager::ReadFile(tmpdir / "b" / "a") == "bar"); + CHECK(*FileSystemManager::ReadSymlink(tmpdir / "b" / "a") == "bar"); REQUIRE(FileSystemManager::RemoveDirectory(tmpdir, true)); } diff --git a/test/end-to-end/TARGETS b/test/end-to-end/TARGETS index 0e81d749..be1f642f 100644 --- a/test/end-to-end/TARGETS +++ b/test/end-to-end/TARGETS @@ -58,6 +58,7 @@ , [["./", "git-import", "TESTS"], "git-import"] , [["./", "gc", "TESTS"], "gc"] , [["./", "execution-service", "TESTS"], "execution-service"] + , [["./", "symlinks", "TESTS"], "symlinks"] ] } } diff --git a/test/end-to-end/symlinks/TARGETS b/test/end-to-end/symlinks/TARGETS new file mode 100644 index 00000000..12add451 --- /dev/null +++ b/test/end-to-end/symlinks/TARGETS @@ -0,0 +1,8 @@ +{ "stage-links": + { "type": ["end-to-end", "with remote"] + , "name": ["stage-links"] + , "test": ["stage-links.sh"] + , "deps": [["end-to-end", "tool-under-test"]] + } +, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["stage-links"]} +} diff --git a/test/end-to-end/symlinks/stage-links.sh b/test/end-to-end/symlinks/stage-links.sh new file mode 100644 index 00000000..b8234d2a --- /dev/null +++ b/test/end-to-end/symlinks/stage-links.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# Copyright 2023 Huawei Cloud Computing Technology Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +readonly JUST="${PWD}/bin/tool-under-test" + +touch ROOT +cat > TARGETS <