diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-06-05 11:16:34 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-06-05 12:41:38 +0200 |
commit | e4214ea95874bdd5bc059d0892f90c09df7b664d (patch) | |
tree | 293631c1ce139d95c9ad2d765e40a079041fae6f /test | |
parent | 06bb4f11a21aae5713d75b496145f6621302ae3a (diff) | |
download | justbuild-e4214ea95874bdd5bc059d0892f90c09df7b664d.tar.gz |
Add a test verifying that no working directory is needed
Diffstat (limited to 'test')
-rw-r--r-- | test/end-to-end/cli/TARGETS | 9 | ||||
-rw-r--r-- | test/end-to-end/cli/pwd.sh | 94 |
2 files changed, 102 insertions, 1 deletions
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 <<EOF +{"repositories": {"": {"workspace_root": ["file", "${SRCDIR}"]}}} +EOF +REPOS=$(realpath repos.json) +cat "${REPOS}" + +# Verify that building on a sufficiently absolute configuraiton +# does not require a current working directory + +ENTERED_DIR_FILE="${ROOT}/entered" +WORK_DIR="${ROOT}/working-directory" +WORK_DIR_REMOVED_FILE="${ROOT}/removed" +DONE_FILE="${ROOT}/build_attempt_done" +WORKER_LOG="${ROOT}/log" + +cat > worker.sh <<EOF +#!/bin/sh +cd "${WORK_DIR}" +touch "${ENTERED_DIR_FILE}" +while [ ! -f "${WORK_DIR_REMOVED_FILE}" ] +do + sleep 1 +done +${TOOL} install --local-build-root "${ROOT}" -C "${REPOS}" -o "${OUTDIR}" > "${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 |