diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-01-23 17:11:20 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-01-24 18:57:50 +0100 |
commit | 3336390955466991aa3d8518dbe217114da9b3a3 (patch) | |
tree | cbcd1fbaf1c53e4c9574c42ec5cbed435c53a7b8 | |
parent | 617fad94f3ea4566ad4124d2a3731d633bd84b9d (diff) | |
download | justbuild-3336390955466991aa3d8518dbe217114da9b3a3.tar.gz |
Add a test verifying that just-mr reports the correct tool names
... regardless of the names chosen during packaging.
-rw-r--r-- | test/end-to-end/cli/TARGETS | 21 | ||||
-rwxr-xr-x | test/end-to-end/cli/just-mr-reporting.sh | 69 |
2 files changed, 89 insertions, 1 deletions
diff --git a/test/end-to-end/cli/TARGETS b/test/end-to-end/cli/TARGETS index 0b069c22..17e76c22 100644 --- a/test/end-to-end/cli/TARGETS +++ b/test/end-to-end/cli/TARGETS @@ -28,9 +28,28 @@ , "test": ["build-p.sh"] , "deps": [["end-to-end", "tool-under-test"]] } +, "just-mr reporting": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["just-mr-reporting"] + , "test": ["just-mr-reporting.sh"] + , "deps": + [["end-to-end", "tool-under-test"], ["end-to-end", "mr-tool-under-test"]] + , "keep": ["log/warning.txt"] + } , "TESTS": { "type": "install" , "tainted": ["test"] - , "deps": ["defaults", "pwd", "install", "build -P", "analyse"] + , "arguments_config": ["TEST_BOOTSTRAP_JUST_MR"] + , "deps": + { "type": "++" + , "$1": + [ ["defaults", "pwd", "install", "build -P", "analyse"] + , { "type": "if" + , "cond": {"type": "var", "name": "TEST_BOOTSTRAP_JUST_MR"} + , "then": [] + , "else": ["just-mr reporting"] + } + ] + } } } diff --git a/test/end-to-end/cli/just-mr-reporting.sh b/test/end-to-end/cli/just-mr-reporting.sh new file mode 100755 index 00000000..c9bf2c61 --- /dev/null +++ b/test/end-to-end/cli/just-mr-reporting.sh @@ -0,0 +1,69 @@ +#!/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 -e + +BUILDROOT="${TEST_TMPDIR}/build-root" +OUTDIR="${TEST_TMPDIR}/out" + +mkdir tools +ln -s $(realpath ./bin/tool-under-test) tools/the-build-tool +ln -s $(realpath ./bin/mr-tool-under-test) tools/the-multi-repo-tool +export PATH=$(realpath tools):${PATH} + +mkdir -p log +LOGDIR="$(realpath log)" + +mkdir work +cd work +touch ROOT + +cat > repos.json <<'EOF' +{ "repositories": + { "": + {"repository": {"type": "file", "path": ".", "pragma": {"to_git": true}}} + } +} +EOF + +cat > TARGETS <<'EOF' +{ "generated": + { "type": "generic" + , "outs": ["out.txt"] + , "cmds": ["echo Hello WoRlD > out.txt"] + } +, "": {"type": "export", "target": "generated"} +} +EOF + +the-multi-repo-tool --norc --just the-build-tool \ + --local-build-root "${BUILDROOT}" \ + --log-limit 1 -f "${LOGDIR}/warning.txt" \ + install -o "${OUTDIR}" 2>&1 + +# Verify that the build yields the expected result + +grep WoRlD "${OUTDIR}/out.txt" + +# Verify that the reported warning contains the actual +# tool names, not some hardcoded string + +grep the-build-tool "${LOGDIR}/warning.txt" +grep the-multi-repo-tool "${LOGDIR}/warning.txt" +grep 'just build' "${LOGDIR}/warning.txt" && exit 1 +grep 'just-mr' "${LOGDIR}/warning.txt" && exit 1 + + +echo OK |