diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-11-16 11:38:23 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2022-11-16 15:09:05 +0100 |
commit | fbc34ed2cb3e42a2d5df6db67a362b127df42f7d (patch) | |
tree | 5ea1e234f4db3e07bf9bec047bd27d7657c881f7 /test | |
parent | c3b10ee7c9320ed6cf5daec6310b0296812ea86a (diff) | |
download | justbuild-fbc34ed2cb3e42a2d5df6db67a362b127df42f7d.tar.gz |
Fix effective configuration computation in configure
While the built-in "configure" rule is forwarding the result of
the configured target, its own effective configuration is not that
of the configured target. The effective configuration is defined
to be that part of the incoming configuration that can potentially
influence the result of that target; in particular, this includes
variables read in defining the configuration transition.
Diffstat (limited to 'test')
-rw-r--r-- | test/end-to-end/targets/TARGETS | 7 | ||||
-rw-r--r-- | test/end-to-end/targets/configure-vars.sh | 69 |
2 files changed, 76 insertions, 0 deletions
diff --git a/test/end-to-end/targets/TARGETS b/test/end-to-end/targets/TARGETS index 31f4f900..13de53ad 100644 --- a/test/end-to-end/targets/TARGETS +++ b/test/end-to-end/targets/TARGETS @@ -28,6 +28,12 @@ , "test": ["configure-target.sh"] , "deps": [["test/end-to-end", "tool-under-test"]] } +, "configure variables": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["configure-vars"] + , "test": ["configure-vars.sh"] + , "deps": [["test/end-to-end", "tool-under-test"]] + } , "TESTS": { "type": "install" , "tainted": ["test"] @@ -37,6 +43,7 @@ , "resolution of built-in rules" , "glob expansion" , "configure target name" + , "configure variables" ] } } diff --git a/test/end-to-end/targets/configure-vars.sh b/test/end-to-end/targets/configure-vars.sh new file mode 100644 index 00000000..e55581f7 --- /dev/null +++ b/test/end-to-end/targets/configure-vars.sh @@ -0,0 +1,69 @@ +#!/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 + +TOOL=$(realpath ./bin/tool-under-test) +mkdir -p .root +BUILDROOT=$(realpath .root) +mkdir -p out +OUTDIR=$(realpath out) + +mkdir src +cd src +touch ROOT +cat > TARGETS <<'EOI' +{ "copy foo": + { "type": "configure" + , "arguments_config": ["FOO"] + , "target": "use bar" + , "config": + { "type": "let*" + , "bindings": + [["BAR", {"type": "var", "name": "FOO"}], ["FOO", "REDACTED"]] + , "body": {"type": "env", "vars": ["BAR", "FOO"]} + } + } +, "use bar": + { "type": "file_gen" + , "arguments_config": ["BAR"] + , "data": {"type": "var", "name": "BAR", "default": "bar"} + , "name": "out.txt" + } +} +EOI + + +echo +${TOOL} analyse --local-build-root "${BUILDROOT}" \ + --dump-vars "${OUTDIR}/vars.json" \ + --dump-targets "${OUTDIR}/targets.json" \ + -D '{"FOO": "the value", "BAR": "unused!"}' 'copy foo' 2>&1 +echo +cat "${OUTDIR}/vars.json" +echo +cat "${OUTDIR}/targets.json" +echo +copy_configs=$(cat "${OUTDIR}/targets.json" | jq -acM '."@" | ."" | ."" | ."copy foo"') +echo "${copy_configs}" +[ $(echo "${copy_configs}" | jq length) -eq 1 ] +config=$(echo "${copy_configs}" | jq '.[0]') +echo $config +[ $(echo "$config" | jq -acM 'keys') = '["FOO"]' ] +echo "$config" | jq -acM '."FOO"' +[ "$(echo "$config" | jq -acM '."FOO"')" = '"the value"' ] +[ "$(cat "${OUTDIR}/vars.json")" = '["FOO"]' ] + +echo DONE |