summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/end-to-end/TARGETS5
-rw-r--r--test/end-to-end/just-lock/TARGETS67
-rw-r--r--test/end-to-end/just-lock/absent.sh115
-rw-r--r--test/end-to-end/just-lock/computed.sh211
-rwxr-xr-xtest/end-to-end/just-lock/deduplicate.sh165
-rw-r--r--test/end-to-end/just-lock/git-imports.sh122
6 files changed, 685 insertions, 0 deletions
diff --git a/test/end-to-end/TARGETS b/test/end-to-end/TARGETS
index c78d2c05..c5fe7472 100644
--- a/test/end-to-end/TARGETS
+++ b/test/end-to-end/TARGETS
@@ -10,6 +10,10 @@
["@", "src", "", "bin/just-deduplicate-repos.py"]
}
}
+, "lock-tool-under-test":
+ { "type": "install"
+ , "files": {"bin/lock-tool-under-test": ["@", "src", "", "bin/just-lock.py"]}
+ }
, "remote tests (unconfigured)":
{ "type": ["@", "rules", "test", "suite"]
, "arguments_config": ["TEST_COMPATIBLE_REMOTE", "TEST_BOOTSTRAP_JUST_MR"]
@@ -66,6 +70,7 @@
, ["./", "gc", "TESTS"]
, ["./", "generated-binary", "TESTS"]
, ["./", "git-import", "TESTS"]
+ , ["./", "just-lock", "TESTS"]
, ["./", "symlinks", "TESTS"]
, ["./", "target-cache", "TESTS"]
, ["./", "target-tests", "TESTS"]
diff --git a/test/end-to-end/just-lock/TARGETS b/test/end-to-end/just-lock/TARGETS
new file mode 100644
index 00000000..360dd00c
--- /dev/null
+++ b/test/end-to-end/just-lock/TARGETS
@@ -0,0 +1,67 @@
+{ "git-imports":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["git-imports"]
+ , "test": ["git-imports.sh"]
+ , "deps":
+ [ ["", "mr-tool-under-test"]
+ , ["", "tool-under-test"]
+ , ["end-to-end", "git-import-under-test"]
+ , ["end-to-end", "lock-tool-under-test"]
+ ]
+ }
+, "deduplicate":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["deduplicate"]
+ , "test": ["deduplicate.sh"]
+ , "deps":
+ [ ["", "mr-tool-under-test"]
+ , ["", "tool-under-test"]
+ , ["end-to-end", "deduplicate-tool-under-test"]
+ , ["end-to-end", "lock-tool-under-test"]
+ ]
+ , "keep":
+ [ "repos-keep.json"
+ , "actions-keep.json"
+ , "repos.json"
+ , "actions.json"
+ , "repos-dedup.json"
+ ]
+ }
+, "absent":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["absent"]
+ , "test": ["absent.sh"]
+ , "deps":
+ [ ["", "mr-tool-under-test"]
+ , ["", "tool-under-test"]
+ , ["end-to-end", "lock-tool-under-test"]
+ ]
+ }
+, "computed":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["computed"]
+ , "test": ["computed.sh"]
+ , "deps":
+ [ ["", "mr-tool-under-test"]
+ , ["", "tool-under-test"]
+ , ["end-to-end", "lock-tool-under-test"]
+ ]
+ , "keep": ["repos.json", "actions.json"]
+ }
+, "TESTS":
+ { "type": ["@", "rules", "test", "suite"]
+ , "arguments_config": ["TEST_BOOTSTRAP_JUST_MR"]
+ , "stage": ["just-lock"]
+ , "deps":
+ { "type": "++"
+ , "$1":
+ [ ["deduplicate", "absent"]
+ , { "type": "if"
+ , "cond": {"type": "var", "name": "TEST_BOOTSTRAP_JUST_MR"}
+ , "then": []
+ , "else": ["git-imports", "computed"]
+ }
+ ]
+ }
+ }
+}
diff --git a/test/end-to-end/just-lock/absent.sh b/test/end-to-end/just-lock/absent.sh
new file mode 100644
index 00000000..9539f8b8
--- /dev/null
+++ b/test/end-to-end/just-lock/absent.sh
@@ -0,0 +1,115 @@
+#!/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 -eu
+
+readonly JUST_LOCK="${PWD}/bin/lock-tool-under-test"
+readonly REPO_DIRS="${TEST_TMPDIR}/repos"
+readonly WRKDIR="${PWD}"
+
+mkdir -p "${REPO_DIRS}/foo/"
+cd "${REPO_DIRS}/foo"
+cat > repos.json <<'EOF'
+{ "repositories":
+ { "":
+ {"repository": {"type": "file", "path": "src"}, "bindings": {"bar": "bar"}}
+ , "bar":
+ { "repository":
+ { "type": "archive"
+ , "content": "4d86bdf4d07535db3754e6cbf30a6fc81aaa2cc1"
+ , "fetch": "https://example.org/v1.2.3"
+ }
+ }
+ }
+}
+EOF
+git init 2>&1
+git checkout --orphan foomaster 2>&1
+git config user.name 'N.O.Body' 2>&1
+git config user.email 'nobody@example.org' 2>&1
+git add . 2>&1
+git commit -m 'Add foo' 2>&1
+
+mkdir -p "${WRKDIR}"
+cd "${WRKDIR}"
+touch ROOT
+cat > repos.in.json <<EOF
+{ "repositories":
+ { "":
+ { "repository": {"type": "file", "path": "."}
+ , "bindings":
+ { "foo": "foo"
+ , "bar": "my/internal/bar/version"
+ , "file-foo": "file-foo"
+ , "file-bar": "file-bar"
+ }
+ }
+ , "my/internal/bar/version":
+ { "repository":
+ { "type": "archive"
+ , "content": "4d86bdf4d07535db3754e6cbf30a6fc81aaa2cc1"
+ , "fetch": "https://example.org/v1.2.3"
+ }
+ }
+ , "file-foo":
+ { "repository":
+ {"type": "file", "path": "third_party", "pragma": {"to_git": true}}
+ }
+ , "file-bar": {"repository": {"type": "file", "path": "third_party"}}
+ }
+, "imports":
+ [ { "source": "git"
+ , "repos":
+ [ { "alias": "foo"
+ , "pragma": {"absent": true}
+ }
+ ]
+ , "url": "${REPO_DIRS}/foo"
+ , "mirrors": ["http://primary.example.org/foo"]
+ , "branch": "foomaster"
+ , "inherit_env": ["AUTH_VAR_FOO"]
+ }
+ ]
+}
+EOF
+"${JUST_LOCK}" -C repos.in.json -o repos.json
+cat repos.json
+echo
+
+# Both bar repos should be unified by deduplication
+FOO_BAR=$(jq '.repositories.foo.bindings.bar' repos.json)
+echo "Bar repo of foo: ${FOO_BAR}"
+INTERNAL_BAR=$(jq '.repositories."".bindings.bar' repos.json)
+echo "Internal bar repo: ${INTERNAL_BAR}"
+[ "${FOO_BAR}" = "${INTERNAL_BAR}" ]
+jq '.repositories.'"$FOO_BAR" repos.json > bar.json
+cat bar.json
+# ... and the pragma empty, as the internal bar is part of the merge
+# and that repository cannot be absent.
+[ $(jq '.pragma?' bar.json) = "null" ]
+
+# Also, both file repositories should be unified
+FILE_FOO=$(jq '.repositories."".bindings."file-foo"' repos.json)
+echo "file-foo of '' is now ${FILE_FOO}"
+FILE_BAR=$(jq '.repositories."".bindings."file-bar"' repos.json)
+echo "file-bar of '' is now ${FILE_BAR}"
+[ "${FILE_FOO}" = "${FILE_BAR}" ]
+jq '.repositories.'"$FILE_FOO" repos.json > local.json
+cat local.json
+# The to_git pragma should be preserved
+[ $(jq '.repository.pragma."to_git"' local.json) = "true" ]
+
+echo OK
diff --git a/test/end-to-end/just-lock/computed.sh b/test/end-to-end/just-lock/computed.sh
new file mode 100644
index 00000000..f31984db
--- /dev/null
+++ b/test/end-to-end/just-lock/computed.sh
@@ -0,0 +1,211 @@
+#!/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
+
+readonly JUST_LOCK="${PWD}/bin/lock-tool-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}"
+
+# Set up repo foo
+mkdir -p "${REPO_DIRS}/foo/src"
+cd "${REPO_DIRS}/foo"
+cat > repos.json <<'EOF'
+{ "repositories":
+ { "":
+ { "repository":
+ { "type": "file"
+ , "path": "src"
+ , "pragma": {"to_git": true}
+ }
+ }
+ }
+}
+EOF
+cat > src/TARGETS <<'EOF'
+{ "": {"type": "export", "target": "gen"}
+, "gen":
+ {"type": "generic", "outs": ["foo.txt"], "cmds": ["echo -n FOO > foo.txt"]}
+}
+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
+
+# Set up repo bar
+mkdir -p "${REPO_DIRS}/bar"
+cd "${REPO_DIRS}/bar"
+cat > repos.in.json <<EOF
+{ "repositories":
+ { "": {"repository": "inner", "target_root": "computed_src"}
+ , "inner":
+ { "repository": {"type": "file", "path": ".", "pragma": {"to_git": true}}
+ , "bindings": {"DoNotImport": "Missing"}
+ }
+ , "src":
+ { "repository": {"type": "file", "path": "src", "pragma": {"to_git": true}}
+ , "bindings": {"foo": "foo"}
+ }
+ , "computed_src":
+ { "repository":
+ { "type": "computed"
+ , "repo": "src"
+ , "target": ["", ""]
+ , "config": {"COUNT": "10"}
+ }
+ }
+ , "root_inner":
+ { "repository": {"type": "file", "path": ".", "pragma": {"to_git": true}}
+ , "bindings": {"AlsoDoNotImport": "AlsoMissing"}
+ }
+ , "root": {"repository": "root_inner", "bindings": {"foo": "foo"}}
+ , "bar_root":
+ { "repository":
+ { "type": "computed"
+ , "repo": "root"
+ , "target": ["", ""]
+ , "config": {"COUNT": "12"}
+ }
+ }
+ }
+, "imports":
+ [ { "source": "git"
+ , "repos": [{"alias": "foo"}]
+ , "url": "${REPO_DIRS}/foo"
+ , "branch": "foomaster"
+ }
+ ]
+}
+EOF
+
+"${JUST_LOCK}" -C repos.in.json -o repos.json
+cat repos.json
+
+cat > generate.py <<'EOF'
+import json
+import sys
+
+COUNT = int(sys.argv[1])
+targets = {}
+for i in range(COUNT):
+ targets["%d" % i] = {"type": "generic", "outs": ["%d.txt" %i],
+ "cmds": ["seq 0 %d > %d.txt" % (i, i)]}
+targets[""] = {"type": "export", "target": "gen"}
+targets["gen"] = {"type": "generic",
+ "deps": ["%d" % i for i in range(COUNT)],
+ "cmds": [" ".join(["cat"] + ["%d.txt" % i for i in range(COUNT)]
+ + ["> out"])],
+ "outs": ["out"]}
+print (json.dumps(targets, indent=2))
+EOF
+cat > TARGETS <<'EOF'
+{ "": {"type": "export", "flexible_config": ["COUNT"], "target": "generate"}
+, "generate":
+ { "type": "generic"
+ , "arguments_config": ["COUNT"]
+ , "outs": ["TARGETS", "bar.txt"]
+ , "deps": ["generate.py", ["@", "foo", "", ""]]
+ , "cmds":
+ [ { "type": "join"
+ , "separator": " "
+ , "$1":
+ [ "python3"
+ , "generate.py"
+ , {"type": "var", "name": "COUNT"}
+ , ">"
+ , "TARGETS"
+ ]
+ }
+ , "cat foo.txt | tr A-Z a-z > bar.txt"
+ ]
+ }
+}
+EOF
+mkdir src
+cp generate.py src/generate.py
+cp TARGETS src/TARGETS
+
+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
+
+# Set up repo to build
+mkdir -p "${WRKDIR}"
+cd "${WRKDIR}"
+touch ROOT
+cat > TARGETS <<'EOF'
+{ "": {"type": "export", "target": "gen"}
+, "gen":
+ { "type": "generic"
+ , "cmds": ["cat bar.txt init.txt > out.txt"]
+ , "outs": ["out.txt"]
+ , "deps": [["@", "bar_root", "", ""], "init"]
+ }
+, "init":
+ { "type": "generic"
+ , "cmds": ["cat foo.txt bar.txt > init.txt"]
+ , "outs": ["init.txt"]
+ , "deps": [["@", "foo", "", ""], ["@", "bar", "", ""]]
+ }
+}
+EOF
+cat > repos.in.json <<EOF
+{ "repositories":
+ { "":
+ { "repository": {"type": "file", "path": ".", "pragma": {"to_git": true}}
+ , "bindings": {"foo": "foo", "bar": "bar", "bar_root": "bar_root"}
+ }
+ }
+, "imports":
+ [ { "source": "git"
+ , "repos": [{"alias": "foo"}]
+ , "url": "${REPO_DIRS}/foo"
+ , "branch": "foomaster"
+ }
+ , { "source": "git"
+ , "repos": [{"alias": "bar"}]
+ , "url": "${REPO_DIRS}/bar"
+ , "branch": "barmaster"
+ }
+ , { "source": "git"
+ , "repos": [{"repo": "bar_root"}]
+ , "url": "${REPO_DIRS}/bar"
+ , "branch": "barmaster"
+ }
+ ]
+}
+EOF
+"${JUST_LOCK}" -C repos.in.json -o repos.json
+
+echo
+cat repos.json
+grep DoNotImport && exit 1 || : # we should not bring in unneeded bindings
+echo
+"${JUST_MR}" -C repos.json --norc --just "${JUST}" \
+ --local-build-root "${LBR}" analyse \
+ -L '["env", "PATH='"${PATH}"'"]' 2>&1
+
+echo "OK"
diff --git a/test/end-to-end/just-lock/deduplicate.sh b/test/end-to-end/just-lock/deduplicate.sh
new file mode 100755
index 00000000..dad40c2d
--- /dev/null
+++ b/test/end-to-end/just-lock/deduplicate.sh
@@ -0,0 +1,165 @@
+#!/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 -eu
+
+readonly DEDUPLICATE="${PWD}/bin/deduplicate-tool-under-test"
+readonly JUST_LOCK="${PWD}/bin/lock-tool-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}"
+
+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": "generic", "outs": ["foo.txt"], "cmds": ["echo -n FOO > foo.txt"]}
+}
+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.in.json <<EOF
+{ "repositories":
+ { "":
+ {"repository": {"type": "file", "path": ""}, "bindings": {"foo": "foo"}}
+ }
+, "imports":
+ [ { "source": "git"
+ , "repos": [{"alias": "foo"}]
+ , "url": "${REPO_DIRS}/foo"
+ , "branch": "foomaster"
+ }
+ ]
+}
+EOF
+"${JUST_LOCK}" -C repos.in.json -o repos.json
+cat repos.json
+echo
+cat > TARGETS <<'EOF'
+{ "":
+ { "type": "generic"
+ , "outs": ["bar.txt"]
+ , "cmds": ["cat foo.txt | tr A-Z a-z > bar.txt"]
+ , "deps": [["@", "foo", "", ""]]
+ }
+}
+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
+
+# Check "keep" field works by keeping both version of foo (direct and transient)
+cat > repos.in.json <<EOF
+{ "repositories":
+ { "":
+ { "repository": {"type": "file", "path": "."}
+ , "bindings": {"foo": "foo", "bar": "bar"}
+ }
+ }
+, "imports":
+ [ { "source": "git"
+ , "repos": [{"alias": "foo"}]
+ , "url": "${REPO_DIRS}/foo"
+ , "branch": "foomaster"
+ }
+ , { "source": "git"
+ , "repos": [{"alias": "bar"}]
+ , "url": "${REPO_DIRS}/bar"
+ , "branch": "barmaster"
+ }
+ ]
+, "keep": ["foo", "bar/foo"]
+}
+EOF
+"${JUST_LOCK}" -C repos.in.json -o repos-keep.json
+cat repos-keep.json
+echo
+"${JUST_MR}" -C repos-keep.json --norc --just "${JUST}" \
+ --local-build-root "${LBR}" analyse \
+ --dump-plain-graph actions-keep.json 2>&1
+echo
+
+# Check that deduplication (performed by default) works as expected
+cat > repos.in.json <<EOF
+{ "repositories":
+ { "":
+ { "repository": {"type": "file", "path": "."}
+ , "bindings": {"foo": "foo", "bar": "bar"}
+ }
+ }
+, "imports":
+ [ { "source": "git"
+ , "repos": [{"alias": "foo"}]
+ , "url": "${REPO_DIRS}/foo"
+ , "branch": "foomaster"
+ }
+ , { "source": "git"
+ , "repos": [{"alias": "bar"}]
+ , "url": "${REPO_DIRS}/bar"
+ , "branch": "barmaster"
+ }
+ ]
+}
+EOF
+"${JUST_LOCK}" -C repos.in.json -o repos.json
+cat repos.json
+echo
+"${JUST_MR}" -C repos.json --norc --just "${JUST}" \
+ --local-build-root "${LBR}" analyse \
+ --dump-plain-graph actions.json 2>&1
+echo
+# Check against existing tooling
+cat repos-keep.json | "${DEDUPLICATE}" > repos-dedup.json
+jq . repos.json > file_a.json
+jq . repos-dedup.json > file_b.json
+cmp file_a.json file_b.json
+
+# Verify that deduplication reduces the number of repositories, but does
+# not change the action graph (except for the origins of the actions).
+[ $(jq -aM '.repositories | length' "repos.json") -lt $(jq -aM '.repositories | length' "repos-keep.json") ]
+cmp actions-keep.json actions.json
+
+echo "OK"
diff --git a/test/end-to-end/just-lock/git-imports.sh b/test/end-to-end/just-lock/git-imports.sh
new file mode 100644
index 00000000..1f7c0cb0
--- /dev/null
+++ b/test/end-to-end/just-lock/git-imports.sh
@@ -0,0 +1,122 @@
+#!/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 -eu
+
+readonly GIT_IMPORT="${PWD}/bin/git-import-under-test"
+readonly JUST_LOCK="${PWD}/bin/lock-tool-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.in.json <<EOF
+{ "repositories":
+ { "":
+ { "repository": {"type": "file", "path": "."}
+ , "bindings": {"foo": "foo", "bar": "bar"}
+ }
+ }
+ , "imports":
+ [ { "source": "git"
+ , "repos": [{"alias": "foo"}]
+ , "url": "${REPO_DIRS}/foo"
+ , "branch": "foomaster"
+ }
+ , { "source": "git"
+ , "repos": [{"alias": "bar"}]
+ , "url": "${REPO_DIRS}/bar"
+ , "branch": "barmaster"
+ }
+ ]
+}
+EOF
+echo
+cat repos.in.json
+
+"${JUST_LOCK}" -C repos.in.json -o repos.json
+
+echo
+cat repos.json
+echo
+"${JUST_MR}" -L '["env", "PATH='"${PATH}"'"]' --norc --just "${JUST}" --local-build-root "${LBR}" install -o "${OUT}" 2>&1
+echo
+cat "${OUT}/out.txt"
+echo
+grep -q FOOBAR "${OUT}/out.txt"
+
+# Verify that results match a chained import, as no deduplication is to be done
+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-chained.json
+jq . repos.json > repos.json
+jq . repos-chained.json > repos-chained.json
+diff repos.json repos-chained.json
+
+echo "OK"