diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/end-to-end/just-mr/TARGETS | 14 | ||||
-rw-r--r-- | test/end-to-end/just-mr/fetch-absent.sh | 68 | ||||
-rwxr-xr-x | test/end-to-end/with_serve_test_runner.py | 16 |
3 files changed, 94 insertions, 4 deletions
diff --git a/test/end-to-end/just-mr/TARGETS b/test/end-to-end/just-mr/TARGETS index e6017fc6..92be1ea6 100644 --- a/test/end-to-end/just-mr/TARGETS +++ b/test/end-to-end/just-mr/TARGETS @@ -80,6 +80,19 @@ , "deps": [["end-to-end", "mr-tool-under-test"], ["end-to-end", "tool-under-test"]] } +, "fetch-absent": + { "type": ["end-to-end", "with serve"] + , "name": ["fetch-absent"] + , "test": ["fetch-absent.sh"] + , "deps": + [["end-to-end", "mr-tool-under-test"], ["end-to-end", "tool-under-test"]] + , "repos": ["fetch-absent (data)"] + } +, "fetch-absent (data)": + { "type": "generic" + , "out_dirs": ["src"] + , "cmds": ["for i in `seq 1 10` ; do echo $i > src/$i.txt ; done"] + } , "TESTS": { "type": "install" , "tainted": ["test"] @@ -99,6 +112,7 @@ , "git-tree-verbosity" , "defaults" , "absent-roots" + , "fetch-absent" ] , { "type": "if" , "cond": {"type": "var", "name": "TEST_COMPATIBLE_REMOTE"} diff --git a/test/end-to-end/just-mr/fetch-absent.sh b/test/end-to-end/just-mr/fetch-absent.sh new file mode 100644 index 00000000..39b89c4a --- /dev/null +++ b/test/end-to-end/just-mr/fetch-absent.sh @@ -0,0 +1,68 @@ +#!/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 + +env + +readonly JUST="${PWD}/bin/tool-under-test" +readonly JUST_MR="${PWD}/bin/mr-tool-under-test" +readonly LBR="${TEST_TMPDIR}/local-build-root" + +mkdir work +cd work +touch ROOT +cat > repos.json <<EOF +{ "repositories": + { "": + { "repository": + { "type": "git" + , "commit": "$COMMIT_0" + , "pragma": {"absent": true} + , "repository": "http://non-existent.example.org/data.git" + , "branch": "master" + , "subdir": "src" + } + , "target_root": "targets" + } + , "targets": {"repository": {"type": "file", "path": "targets"}} + } +} +EOF +mkdir targets +cat > targets/TARGETS <<'EOF' +{ "": + { "type": "generic" + , "outs": ["out.txt"] + , "cmds": ["head -c 1 4.txt > out.txt", "cat 2.txt >> out.txt"] + , "deps": ["4.txt", "2.txt"] + } +} +EOF + +echo +cat repos.json +echo +CONF=$("${JUST_MR}" --norc --local-build-root "${LBR}" \ + --remote-serve-address ${SERVE} \ + -r ${REMOTE_EXECUTION_ADDRESS} \ + --fetch-absent setup) +cat $CONF +echo +"${JUST}" install --local-build-root "${LBR}" -C "${CONF}" -o . 2>&1 +grep 42 out.txt + +echo DONE diff --git a/test/end-to-end/with_serve_test_runner.py b/test/end-to-end/with_serve_test_runner.py index dbbd4237..b8d7de72 100755 --- a/test/end-to-end/with_serve_test_runner.py +++ b/test/end-to-end/with_serve_test_runner.py @@ -44,6 +44,14 @@ def dump_results() -> None: f.write("%s\n" % (stderr, )) +def run_cmd(cmd: List[str], + *, + env: Any = None, + stdout: Any = subprocess.DEVNULL, + stderr: Any = None, + cwd: str): + subprocess.run(cmd, cwd=cwd, env=env, stdout=stdout, stderr=stderr) + def get_remote_execution_address(d: Json) -> str: return "%s:%d" % (d["interface"], int(d["port"])) @@ -106,7 +114,7 @@ g_REMOTE_EXECUTION_ADDRESS = get_remote_execution_address(info) SERVE_INFO = os.path.join(REMOTE_DIR, "serve-info.json") SERVE_CONFIG_FILE = os.path.join(REMOTE_DIR, "serve.json") -serve_config = { +serve_config : Json = { "local build root": SERVE_DIR, "logging": {"limit": 6, "plain": True}, "execution endpoint": {"address": g_REMOTE_EXECUTION_ADDRESS}, @@ -139,21 +147,21 @@ for repo in os.listdir("data"): os.path.join(DATA_DIR, repo), target, ) - subprocess.run( + run_cmd( ["git", "init"], cwd=target, env=dict(os.environ, **GIT_NOBODY_ENV), stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL, ) - subprocess.run( + run_cmd( ["git", "add", "-f", "."], cwd=target, env=dict(os.environ, **GIT_NOBODY_ENV), stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL, ) - subprocess.run( + run_cmd( ["git", "commit", "-m", "Content of %s" % (target,)], cwd=target, |