diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-04-02 16:52:13 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-04-05 14:48:26 +0200 |
commit | 37ea6238777dc91b6951241f54457da6ef94abf9 (patch) | |
tree | 076539501511247c40fcad573b84a45d4bb59bde /test | |
parent | 84e9d1b6d97631ef7c332fe2416f82c959d5d8d0 (diff) | |
download | justbuild-37ea6238777dc91b6951241f54457da6ef94abf9.tar.gz |
Add test verifying origin reporting in case of conflicts
Diffstat (limited to 'test')
-rw-r--r-- | test/end-to-end/cli/TARGETS | 7 | ||||
-rwxr-xr-x | test/end-to-end/cli/conflict-report.sh | 168 |
2 files changed, 175 insertions, 0 deletions
diff --git a/test/end-to-end/cli/TARGETS b/test/end-to-end/cli/TARGETS index 2d095530..58a72ca2 100644 --- a/test/end-to-end/cli/TARGETS +++ b/test/end-to-end/cli/TARGETS @@ -51,6 +51,12 @@ [["end-to-end", "tool-under-test"], ["end-to-end", "mr-tool-under-test"]] , "keep": ["src.tar", "reconstructed.tar", "fromstdout.tar"] } +, "conflict report": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["conflict-report"] + , "test": ["conflict-report.sh"] + , "deps": [["end-to-end", "tool-under-test"]] + } , "TESTS": { "type": "install" , "tainted": ["test"] @@ -65,6 +71,7 @@ , "analyse" , "git cas -P" , "install --archive" + , "conflict report" ] , { "type": "if" , "cond": {"type": "var", "name": "TEST_BOOTSTRAP_JUST_MR"} diff --git a/test/end-to-end/cli/conflict-report.sh b/test/end-to-end/cli/conflict-report.sh new file mode 100755 index 00000000..0e605402 --- /dev/null +++ b/test/end-to-end/cli/conflict-report.sh @@ -0,0 +1,168 @@ +#!/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 + +JUST="$(pwd)/bin/tool-under-test" +LBR="${TEST_TMPDIR}/local-build-root" + +mkdir src +cd src +touch ROOT +cat > RULES <<'EOF' +{ "provide": + { "target_fields": ["deps"] + , "expression": + { "type": "RESULT" + , "provides": + { "type": "singleton_map" + , "key": "foo" + , "value": + { "type": "disjoint_map_union" + , "msg": "Dependencies may not overlap" + , "$1": + { "type": "foreach" + , "range": {"type": "FIELD", "name": "deps"} + , "body": + {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "_"}} + } + } + } + } + } +, "use provides": + { "target_fields": ["deps"] + , "expression": + { "type": "RESULT" + , "artifacts": + { "type": "disjoint_map_union" + , "msg": "Provided data may not overlap" + , "$1": + { "type": "foreach" + , "range": {"type": "FIELD", "name": "deps"} + , "body": + { "type": "DEP_PROVIDES" + , "dep": {"type": "var", "name": "_"} + , "provider": "foo" + } + } + } + } + } +} +EOF +cat > TARGETS <<'EOF' +{ "greeting.txt": + { "type": "generic" + , "arguments_config": ["NAME"] + , "outs": ["greeting.txt"] + , "cmds": + [ { "type": "join" + , "$1": + [ { "type": "join_cmd" + , "$1": + [ "echo" + , "Hello" + , {"type": "var", "name": "NAME", "default": "unknown user"} + ] + } + , " > greeting.txt" + ] + } + ] + } +, "world": + { "type": "configure" + , "target": "greeting.txt" + , "config": {"type": "singleton_map", "key": "NAME", "value": "World"} + } +, "another world": + { "type": "configure" + , "target": "greeting.txt" + , "config": {"type": "singleton_map", "key": "NAME", "value": "World"} + } +, "universe": + { "type": "configure" + , "target": "greeting.txt" + , "config": {"type": "singleton_map", "key": "NAME", "value": "Universe"} + } +, "unrelated": + { "type": "generic" + , "outs": ["foo.txt"] + , "cmds": ["echo unrelated > foo.txt"] + } +, "install-conflict": + { "type": "install" + , "dirs": + [ ["world", "."] + , ["unrelated", "."] + , ["universe", "."] + , ["another world", "."] + ] + } +, "rule-conflict": + { "type": "provide" + , "deps": ["world", "unrelated", "universe", "another world"] + } +, "provided world": {"type": "provide", "deps": ["world"]} +, "another provided world": {"type": "provide", "deps": ["another world"]} +, "provided unrelated": {"type": "provide", "deps": ["unrelated"]} +, "provided universe": {"type": "provide", "deps": ["universe"]} +, "provided-conflict": + { "type": "use provides" + , "deps": + [ "provided world" + , "provided unrelated" + , "provided universe" + , "another provided world" + ] + } +} +EOF + +"${JUST}" build --local-build-root "${LBR}" install-conflict \ + -f log --log-limit 0 2>&1 && exit 1 || : +echo +# We expect, in the error message, to see the full-qualified target names +# containing the conflicting artifacts, but not the target not containing +# this artifact. +grep '\["@","","","world"\]' log +grep '\["@","","","another world"\]' log +grep '\["@","","","universe"\]' log +grep '\["@","","","unrelated"\]' log && exit 1 || : +echo +echo + + +"${JUST}" build --local-build-root "${LBR}" rule-conflict \ + -f log --log-limit 0 2>&1 && exit 1 || : +echo +grep '\["@","","","world"\]' log +grep '\["@","","","another world"\]' log +grep '\["@","","","universe"\]' log +grep '\["@","","","unrelated"\]' log && exit 1 || : +echo +echo + +"${JUST}" build --local-build-root "${LBR}" provided-conflict \ + -f log --log-limit 0 2>&1 && exit 1 || : +echo +grep '\["@","","","provided world"\]' log +grep '\["@","","","another provided world"\]' log +grep '\["@","","","provided universe"\]' log +grep '\["@","","","provided unrelated"\]' log && exit 1 || : + +echo +echo OK |