From 8e3feece676226164087666be000314e51ec5f86 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Fri, 12 Feb 2021 21:35:08 +0100 Subject: [PATCH] run-tests: fix interrupt handling for --copy-src Previously, `run-tests.sh --copy-src ...` exited with status 0 (success) when interrupted (SIGINT). It now exits with an error status. --- test/lib/copy-src.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/lib/copy-src.sh b/test/lib/copy-src.sh index 71bc3a2..93be40c 100644 --- a/test/lib/copy-src.sh +++ b/test/lib/copy-src.sh @@ -3,16 +3,16 @@ tmp=$(mktemp -d '/tmp/nix-bitcoin-src.XXXXX') -# Ignore errors from now on -set +e - # Move source cache if it exists (atomic) -mv /tmp/nix-bitcoin-src $tmp/src 2>/dev/null +mv /tmp/nix-bitcoin-src $tmp/src 2>/dev/null || true -rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src && \ - echo "Copied src" && \ - _nixBitcoinInCopySrc=1 $tmp/src/test/run-tests.sh "${args[@]}" +atExit() { + # Set the current src as the source cache (atomic) + mv -T $tmp/src /tmp/nix-bitcoin-src 2>/dev/null || true + rm -rf $tmp +} +trap "atExit" EXIT -# Set the current src as the source cache (atomic) -mv -T $tmp/src /tmp/nix-bitcoin-src 2>/dev/null -rm -rf $tmp +rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src +echo "Copied src" +_nixBitcoinInCopySrc=1 $tmp/src/test/run-tests.sh "${args[@]}"