From dc18781e01d64d2808ad93839e117730b7ca0354 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 10 Dec 2024 10:25:24 +0100 Subject: Add a test building against computed roots with absent base repository --- test/end-to-end/computed-roots/TARGETS | 12 +++- test/end-to-end/computed-roots/absent-base.sh | 73 ++++++++++++++++++++++ test/end-to-end/computed-roots/targets.absent-base | 20 ++++++ 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 test/end-to-end/computed-roots/absent-base.sh create mode 100644 test/end-to-end/computed-roots/targets.absent-base (limited to 'test') diff --git a/test/end-to-end/computed-roots/TARGETS b/test/end-to-end/computed-roots/TARGETS index 5a1c6762..8abea7d7 100644 --- a/test/end-to-end/computed-roots/TARGETS +++ b/test/end-to-end/computed-roots/TARGETS @@ -53,11 +53,21 @@ , "test": ["artifacts-only.sh"] , "deps": [["", "tool-under-test"]] } +, "absent base of root (data)": + {"type": "install", "files": {"TARGETS": "targets.absent-base"}} +, "absent base of root": + { "type": ["end-to-end", "with serve"] + , "name": ["absent-base"] + , "test": ["absent-base.sh"] + , "deps": [["", "tool-under-test"]] + , "repos": ["absent base of root (data)"] + } , "TESTS": { "type": ["@", "rules", "test", "suite"] , "stage": ["computed-roots"] , "deps": - [ "artifacts-only" + [ "absent base of root" + , "artifacts-only" , "basic" , "basic remote build" , "error-reporting" diff --git a/test/end-to-end/computed-roots/absent-base.sh b/test/end-to-end/computed-roots/absent-base.sh new file mode 100644 index 00000000..1be9e901 --- /dev/null +++ b/test/end-to-end/computed-roots/absent-base.sh @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 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 + +env + +readonly ROOT="${PWD}" +readonly JUST="${ROOT}/bin/tool-under-test" +readonly LBR="${TEST_TMPDIR}/local-build-root" +readonly MAIN="${ROOT}/main" +readonly OUT="${TEST_TMPDIR}/out" + +COMPAT="" +if [ "${COMPATIBLE:-}" = "YES" ]; then + COMPAT="--compatible" +fi + + +mkdir -p "${MAIN}" +cd "${MAIN}" + +cat > repo-config.json < targets/TARGETS <<'EOF' +{ "": + { "type": "generic" + , "outs": ["out"] + , "cmds": ["cat *.txt > out"] + , "deps": [["data", ""]] + } +} +EOF +mkdir -p targets/data +cat > targets/data/TARGETS <<'EOF' +{"": {"type": "install", "deps": [["GLOB", null, "*.txt"]]}} +EOF + +echo +echo Build against computed root with absent base +echo +"${JUST}" install -o "${OUT}" -C repo-config.json \ + --local-build-root "${LBR}" \ + --remote-serve-address ${SERVE} \ + -r ${REMOTE_EXECUTION_ADDRESS} ${COMPAT} \ + --log-limit 4 2>&1 +# sanity check output +[ $(cat "${OUT}/out" | wc -l) -eq 55 ] + +echo OK diff --git a/test/end-to-end/computed-roots/targets.absent-base b/test/end-to-end/computed-roots/targets.absent-base new file mode 100644 index 00000000..f87157cb --- /dev/null +++ b/test/end-to-end/computed-roots/targets.absent-base @@ -0,0 +1,20 @@ +{ "": {"type": "export", "target": "data", "flexible_config": ["COUNT"]} +, "data": + { "type": "generic" + , "arguments_config": ["COUNT"] + , "out_dirs": ["data"] + , "cmds": + [ { "type": "join" + , "$1": + [ "COUNT=" + , {"type": "join_cmd", "$1": [{"type": "var", "name": "COUNT"}]} + ] + } + , "mkdir -p data" + , "for i in `seq 1 $COUNT`" + , "do" + , " seq 1 $i > data/count$i.txt" + , "done" + ] + } +} -- cgit v1.2.3