run-tests: add option --copy-src

This commit is contained in:
Erik Arvstedt 2021-02-06 09:38:58 +01:00
parent 803584a288
commit 0a2c8e4864
No known key found for this signature in database
GPG Key ID: 33312B944DD97846
2 changed files with 33 additions and 0 deletions

18
test/lib/copy-src.sh Normal file
View File

@ -0,0 +1,18 @@
# Re-run run-tests.sh in a snapshot copy of the source.
# Maintain /tmp/nix-bitcoin-src as a source cache to minimize copies.
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
rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src && \
echo "Copied src" && \
_nixBitcoinInCopySrc=1 $tmp/src/test/run-tests.sh "${args[@]}"
# Set the current src as the source cache (atomic)
mv -T $tmp/src /tmp/nix-bitcoin-src 2>/dev/null
rm -rf $tmp

View File

@ -42,12 +42,20 @@
# For now, creating NixOS containers requires root permissions. # For now, creating NixOS containers requires root permissions.
# See ./lib/make-container.sh for a complete documentation. # See ./lib/make-container.sh for a complete documentation.
# #
# Run tests from a snapshot copy of the source files
# ./run-tests.sh --copy-src|-c ...
#
# This allows you to continue editing the nix-bitcoin sources while tests are running
# and reading source files.
# Files are copied to /tmp, a caching scheme helps minimizing copies.
#
# To add custom scenarios, set the environment variable `scenarioOverridesFile`. # To add custom scenarios, set the environment variable `scenarioOverridesFile`.
set -eo pipefail set -eo pipefail
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd)
args=("$@")
scenario= scenario=
outLinkPrefix= outLinkPrefix=
ciBuild= ciBuild=
@ -77,6 +85,13 @@ while :; do
shift shift
ciBuild=1 ciBuild=1
;; ;;
--copy-src|-c)
shift
if [[ ! $_nixBitcoinInCopySrc ]]; then
. "$scriptDir/lib/copy-src.sh"
exit
fi
;;
*) *)
break break
esac esac