From e4214ea95874bdd5bc059d0892f90c09df7b664d Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Mon, 5 Jun 2023 11:16:34 +0200 Subject: Add a test verifying that no working directory is needed --- test/end-to-end/cli/TARGETS | 9 ++++- test/end-to-end/cli/pwd.sh | 94 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 test/end-to-end/cli/pwd.sh (limited to 'test') diff --git a/test/end-to-end/cli/TARGETS b/test/end-to-end/cli/TARGETS index b45a0f10..9439767b 100644 --- a/test/end-to-end/cli/TARGETS +++ b/test/end-to-end/cli/TARGETS @@ -4,5 +4,12 @@ , "test": ["defaults.sh"] , "deps": [["end-to-end", "tool-under-test"]] } -, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["defaults"]} +, "pwd": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["pwd"] + , "test": ["pwd.sh"] + , "deps": [["end-to-end", "tool-under-test"]] + } +, "TESTS": + {"type": "install", "tainted": ["test"], "deps": ["defaults", "pwd"]} } diff --git a/test/end-to-end/cli/pwd.sh b/test/end-to-end/cli/pwd.sh new file mode 100644 index 00000000..789ba27e --- /dev/null +++ b/test/end-to-end/cli/pwd.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# Copyright 2022 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 -e + +ROOT=$(pwd) +TOOL=$(realpath ./bin/tool-under-test) +mkdir -p .root +BUILDROOT=$(realpath .root) +mkdir -p out +OUTDIR=$(realpath out) + + +mkdir src +touch src/ROOT +cat > src/TARGETS <<'EOF' +{ "": + { "type": "generic" + , "outs": ["hello.txt"] + , "cmds": ["echo Hello World > hello.txt"] + } +} +EOF +SRCDIR=$(realpath src) + +cat > repos.json < worker.sh < "${WORKER_LOG}" 2>&1 +touch "${DONE_FILE}" +EOF +chmod 755 worker.sh + +echo +cat worker.sh +echo + +mkdir -p "${WORK_DIR}" +echo Created "${WORK_DIR}", starting worker +(./worker.sh) & +echo Wating for the worker to enter its work dir +while [ ! -f "${ENTERED_DIR_FILE}" ] +do + sleep 1 +done +echo Removing work dir +rm -rf "${WORK_DIR}" +touch "${WORK_DIR_REMOVED_FILE}" +echo Waiting for the worker to finish +while [ ! -f "${DONE_FILE}" ] +do + sleep 1 +done +echo Worker finished, output was +cat "${WORKER_LOG}" +echo + +echo Inspecting result +ls "${OUTDIR}" +grep World "${OUTDIR}/hello.txt" + +echo OK -- cgit v1.2.3