diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-01-10 13:57:17 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-01-10 15:54:32 +0100 |
commit | 1b375ec66cfc02aa1abaf9151411aa13de6b0700 (patch) | |
tree | 1990c40846b5a72fe0605f1128641c4f56b3d5d6 /test/end-to-end/git-import | |
parent | a50cf5be7ac73bf97afde3c725a2ce5137962572 (diff) | |
download | justbuild-1b375ec66cfc02aa1abaf9151411aa13de6b0700.tar.gz |
Add basic test for git-import
Diffstat (limited to 'test/end-to-end/git-import')
-rw-r--r-- | test/end-to-end/git-import/TARGETS | 12 | ||||
-rwxr-xr-x | test/end-to-end/git-import/chained-import.sh | 91 |
2 files changed, 103 insertions, 0 deletions
diff --git a/test/end-to-end/git-import/TARGETS b/test/end-to-end/git-import/TARGETS new file mode 100644 index 00000000..4dc63805 --- /dev/null +++ b/test/end-to-end/git-import/TARGETS @@ -0,0 +1,12 @@ +{ "chained-import": + { "type": ["@", "rules", "shell/test", "script"] + , "name": ["chained-import"] + , "test": ["chained-import.sh"] + , "deps": + [ ["test/end-to-end", "git-import-under-test"] + , ["test/end-to-end", "mr-tool-under-test"] + , ["test/end-to-end", "tool-under-test"] + ] + } +, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["chained-import"]} +} diff --git a/test/end-to-end/git-import/chained-import.sh b/test/end-to-end/git-import/chained-import.sh new file mode 100755 index 00000000..8eba65ab --- /dev/null +++ b/test/end-to-end/git-import/chained-import.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# Copyright 2023 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 + +readonly GIT_IMPORT="${PWD}/bin/git-import-under-test" +readonly JUST="${PWD}/bin/tool-under-test" +readonly JUST_MR="${PWD}/bin/mr-tool-under-test" +readonly LBR="${TEST_TMPDIR}/local-build-root" +readonly OUT="${TEST_TMPDIR}/build-output" +readonly REPO_DIRS="${TEST_TMPDIR}/repos" +readonly WRKDIR="${PWD}/work" + +mkdir -p "${REPO_DIRS}/foo/src" +cd "${REPO_DIRS}/foo" +cat > repos.json <<'EOF' +{"repositories": {"": {"repository": {"type": "file", "path": "src"}}}} +EOF +cat > src/TARGETS <<'EOF' +{ "": {"type": "file_gen", "name": "foo.txt", "data": "FOO"}} +EOF +git init +git checkout --orphan foomaster +git config user.name 'N.O.Body' +git config user.email 'nobody@example.org' +git add . +git commit -m 'Add foo.txt' 2>&1 + + +mkdir -p "${REPO_DIRS}/bar" +cd "${REPO_DIRS}/bar" +cat > repos.json <<'EOF' +{"repositories": {"": {"repository": {"type": "file", "path": ""}}}} +EOF +cat > TARGETS <<'EOF' +{ "": {"type": "file_gen", "name": "bar.txt", "data": "BAR"}} +EOF +git init +git checkout --orphan barmaster +git config user.name 'N.O.Body' +git config user.email 'nobody@example.org' +git add . +git commit -m 'Add foo.txt' 2>&1 + +mkdir -p "${WRKDIR}" +cd "${WRKDIR}" +touch ROOT +cat > TARGETS <<'EOF' +{ "": + { "type": "generic" + , "cmds": ["cat foo.txt bar.txt > out.txt"] + , "outs": ["out.txt"] + , "deps": [["@", "foo", "", ""], ["@", "bar", "", ""]] + } +} +EOF +cat > repos.template.json <<'EOF' +{ "repositories": + { "": + { "repository": {"type": "file", "path": "."} + , "bindings": {"foo": "foo", "bar": "bar"} + } + } +} +EOF +"${GIT_IMPORT}" -C repos.template.json --as foo -b foomaster "${REPO_DIRS}/foo" \ + | "${GIT_IMPORT}" -C - --as bar -b barmaster "${REPO_DIRS}/bar" > repos.json + +echo +cat repos.json +echo +"${JUST_MR}" --just "${JUST}" --local-build-root "${LBR}" install -o "${OUT}" 2>&1 +echo +cat "${OUT}/out.txt" +echo +grep -q FOOBAR "${OUT}/out.txt" + +echo "OK" |