diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-12 15:38:44 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-02-13 12:08:18 +0100 |
commit | 16af967b70edd686882a083164c0bc41cd6591a8 (patch) | |
tree | 2425eeef746dba9f0d9c3887a486e562602da0fd /test/end-to-end/cli | |
parent | d88898daad7dc654278e3709cf30ead1e4d6c870 (diff) | |
download | justbuild-16af967b70edd686882a083164c0bc41cd6591a8.tar.gz |
Add test that also for trees in the git cas we can follow paths
For a user `just install-cas` will show an entry without revealing
where it found it---as it is content-addressable, it does not matter.
Therefore, verify that accessing paths of a tree object also works
regardless of where the tree is stored.
Diffstat (limited to 'test/end-to-end/cli')
-rw-r--r-- | test/end-to-end/cli/TARGETS | 9 | ||||
-rw-r--r-- | test/end-to-end/cli/git-cas-p.sh | 77 |
2 files changed, 85 insertions, 1 deletions
diff --git a/test/end-to-end/cli/TARGETS b/test/end-to-end/cli/TARGETS index 17e76c22..ae96d466 100644 --- a/test/end-to-end/cli/TARGETS +++ b/test/end-to-end/cli/TARGETS @@ -28,6 +28,13 @@ , "test": ["build-p.sh"] , "deps": [["end-to-end", "tool-under-test"]] } +, "git cas -P": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["git-cas-P"] + , "test": ["git-cas-p.sh"] + , "deps": + [["end-to-end", "tool-under-test"], ["end-to-end", "mr-tool-under-test"]] + } , "just-mr reporting": { "type": ["@", "rules", "shell/test", "script"] , "name": ["just-mr-reporting"] @@ -43,7 +50,7 @@ , "deps": { "type": "++" , "$1": - [ ["defaults", "pwd", "install", "build -P", "analyse"] + [ ["defaults", "pwd", "install", "build -P", "analyse", "git cas -P"] , { "type": "if" , "cond": {"type": "var", "name": "TEST_BOOTSTRAP_JUST_MR"} , "then": [] diff --git a/test/end-to-end/cli/git-cas-p.sh b/test/end-to-end/cli/git-cas-p.sh new file mode 100644 index 00000000..decd4547 --- /dev/null +++ b/test/end-to-end/cli/git-cas-p.sh @@ -0,0 +1,77 @@ +#!/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 + +ROOT="$(pwd)" +JUST="${ROOT}/bin/tool-under-test" +JUST_MR="${ROOT}/bin/mr-tool-under-test" +BUILDROOT="${TEST_TMPDIR}/build-root" +DISTDIR="${TEST_TMPDIR}/distfiles" +mkdir -p "${DISTDIR}" + + +# Create an archive +mkdir -p src/with/some/deep/directory +echo 'Hello World' > src/with/some/deep/directory/hello.txt +tar cvf "${DISTDIR}/src.tar" src +rm -rf src +HASH=$(git hash-object "${DISTDIR}/src.tar") + +echo +echo archive has content $HASH +echo + +# Set up a build root from that archive +mkdir work +cd work +touch ROOT +cat > repos.json <<EOF +{ "repositories": + { "": + { "repository": + { "type": "archive" + , "content": "${HASH}" + , "fetch": "http://example.com/src.tar" + , "subdir": "src/with" + } + } + } +} +EOF +cat repos.json +echo +"${JUST_MR}" --norc --local-build-root "${BUILDROOT}" \ + --distdir "${DISTDIR}" setup > CONF +echo +cat CONF +echo +cat $(cat CONF) +echo +TREE=$(jq -rM '.repositories."".workspace_root[1]' $(cat CONF)) +echo +echo Tree is ${TREE} +echo + +# Verify that we can obtain this tree, as well as its parts +"${JUST}" install-cas --local-build-root "${BUILDROOT}" "${TREE}::t" +"${JUST}" install-cas --local-build-root "${BUILDROOT}" "${TREE}::t" -P some +"${JUST}" install-cas --local-build-root "${BUILDROOT}" "${TREE}::t" -P some/deep +"${JUST}" install-cas --local-build-root "${BUILDROOT}" "${TREE}::t" -P some/deep/directory +"${JUST}" install-cas --local-build-root "${BUILDROOT}" "${TREE}::t" -P some/deep/directory/hello.txt +"${JUST}" install-cas --local-build-root "${BUILDROOT}" "${TREE}::t" -P some/deep/directory/hello.txt -o hello.txt +grep World hello.txt + +echo +echo OK |