From b877561106e0913de7200836d3c5d167d06e3243 Mon Sep 17 00:00:00 2001 From: Sascha Roloff Date: Fri, 2 Sep 2022 14:28:50 +0200 Subject: Fixed tree handling in compatible mode and added regression test --- test/end-to-end/target-cache/TARGETS | 9 ++++ test/end-to-end/target-cache/target-cache-hit.sh | 58 ++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 test/end-to-end/target-cache/TARGETS create mode 100644 test/end-to-end/target-cache/target-cache-hit.sh (limited to 'test/end-to-end/target-cache') 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 <ppp +readonly LOW=100000000 +readonly HIGH=999999999 +readonly RND="p$(hostname)p$(date +%s%N)p$$p$(shuf -i $LOW-$HIGH -n 1)" + +cat > TARGETS <&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 -- cgit v1.2.3