summaryrefslogtreecommitdiff
path: root/test/end-to-end/target-cache
diff options
context:
space:
mode:
authorSascha Roloff <sascha.roloff@huawei.com>2022-09-02 14:28:50 +0200
committerSascha Roloff <sascha.roloff@huawei.com>2022-09-12 14:45:34 +0200
commitb877561106e0913de7200836d3c5d167d06e3243 (patch)
tree39003d30fa4e43c75fd7c7e0e34c9ca8500d9519 /test/end-to-end/target-cache
parent39f3122dd0977a5ea4e58a81ba4665353dda3499 (diff)
downloadjustbuild-b877561106e0913de7200836d3c5d167d06e3243.tar.gz
Fixed tree handling in compatible mode and added regression test
Diffstat (limited to 'test/end-to-end/target-cache')
-rw-r--r--test/end-to-end/target-cache/TARGETS9
-rw-r--r--test/end-to-end/target-cache/target-cache-hit.sh58
2 files changed, 67 insertions, 0 deletions
diff --git a/test/end-to-end/target-cache/TARGETS b/test/end-to-end/target-cache/TARGETS
new file mode 100644
index 00000000..de7ba45b
--- /dev/null
+++ b/test/end-to-end/target-cache/TARGETS
@@ -0,0 +1,9 @@
+{ "target-cache-hit":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["target-cache-hit"]
+ , "test": ["target-cache-hit.sh"]
+ , "deps": [["test/end-to-end", "tool-under-test"], ["", "bin/just-mr.py"]]
+ }
+, "TESTS":
+ {"type": "install", "tainted": ["test"], "deps": ["target-cache-hit"]}
+}
diff --git a/test/end-to-end/target-cache/target-cache-hit.sh b/test/end-to-end/target-cache/target-cache-hit.sh
new file mode 100644
index 00000000..8fbb376c
--- /dev/null
+++ b/test/end-to-end/target-cache/target-cache-hit.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+set -eu
+
+readonly JUST="$PWD/bin/tool-under-test"
+readonly JUST_MR="$PWD/bin/just-mr.py"
+readonly LBRDIR="$TEST_TMPDIR/local-build-root"
+readonly TESTDIR="$TEST_TMPDIR/test-root"
+
+# create project files including an exported target
+mkdir -p "$TESTDIR"
+cd "$TESTDIR"
+touch ROOT
+cat > repos.json <<EOF
+{ "repositories":
+ { "main":
+ {"repository": {"type": "file", "path": ".", "pragma": {"to_git": true}}}
+ }
+}
+EOF
+
+# create random string: p<hostname>p<time[ns]>p<pid>p<random number[9 digits]>
+readonly LOW=100000000
+readonly HIGH=999999999
+readonly RND="p$(hostname)p$(date +%s%N)p$$p$(shuf -i $LOW-$HIGH -n 1)"
+
+cat > TARGETS <<EOF
+{ "main": {"type": "export", "target": ["./", "main-target"]}
+, "main-target":
+ { "type": "generic"
+ , "cmds": ["echo $RND | tee foo.txt out/bar.txt"]
+ , "outs": ["foo.txt"]
+ , "out_dirs": ["out"]
+ }
+}
+EOF
+
+ARGS=""
+if [ "${COMPATIBLE:-}" = "YES" ]; then
+ ARGS="--compatible"
+fi
+
+# build project twice locally to trigger a target cache hit
+export CONF="$("$JUST_MR" -C repos.json --local-build-root="$LBRDIR" setup main)"
+"$JUST" build -C "$CONF" main --local-build-root="$LBRDIR" $ARGS 2>&1
+"$JUST" build -C "$CONF" main --local-build-root="$LBRDIR" $ARGS 2>&1
+
+REMOTE_EXECUTION_ARGS=""
+if [ "${REMOTE_EXECUTION_ADDRESS:-}" != "" ]; then
+ REMOTE_EXECUTION_ARGS="-r $REMOTE_EXECUTION_ADDRESS"
+ if [ "${REMOTE_EXECUTION_PROPERTIES:-}" != "" ]; then
+ REMOTE_EXECUTION_ARGS="$REMOTE_EXECUTION_ARGS --remote-execution-property $REMOTE_EXECUTION_PROPERTIES"
+ fi
+fi
+
+# build project twice remotely to trigger a target cache hit
+"$JUST" build -C "$CONF" main --local-build-root="$LBRDIR" $ARGS $REMOTE_EXECUTION_ARGS 2>&1
+"$JUST" build -C "$CONF" main --local-build-root="$LBRDIR" $ARGS $REMOTE_EXECUTION_ARGS 2>&1