run-tests: allow linking test build results for all scenarios

This commit is contained in:
Erik Arvstedt 2020-08-21 22:36:14 +02:00
parent 91697b1427
commit df790f6766
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -10,8 +10,8 @@
# Test specific scenario # Test specific scenario
# ./run-tests.sh --scenario <scenario> # ./run-tests.sh --scenario <scenario>
# #
# Run test and save result to avoid garbage collection # Run test and link results to avoid garbage collection
# ./run-tests.sh [--scenario <scenario>] build --out-link /tmp/nix-bitcoin-test # ./run-tests.sh [--scenario <scenario>] --out-link-prefix /tmp/nix-bitcoin-test build
# #
# Run interactive test debugging # Run interactive test debugging
# ./run-tests.sh [--scenario <scenario>] debug # ./run-tests.sh [--scenario <scenario>] debug
@ -22,17 +22,33 @@
set -eo pipefail set -eo pipefail
scenario= scenario=
outLinkPrefix=
if [[ $1 == --scenario ]]; then while :; do
case $1 in
--scenario|-s)
if [[ $2 ]]; then if [[ $2 ]]; then
scenario=$2 scenario=$2
shift shift
shift shift
else else
>&2 echo 'Error: "--scenario" requires an argument.' >&2 echo 'Error: "$1" requires an argument.'
exit 1 exit 1
fi fi
fi ;;
--out-link-prefix|-o)
if [[ $2 ]]; then
outLinkPrefix=$2
shift
shift
else
>&2 echo 'Error: "$1" requires an argument.'
exit 1
fi
;;
*)
break
esac
done
numCPUs=${numCPUs:-$(nproc)} numCPUs=${numCPUs:-$(nproc)}
# Min. 800 MiB needed to avoid 'out of memory' errors # Min. 800 MiB needed to avoid 'out of memory' errors
@ -92,7 +108,12 @@ debug() {
# Run the test by building the test derivation # Run the test by building the test derivation
buildTest() { buildTest() {
vmTestNixExpr | nix-build --no-out-link "$@" - if [[ $outLinkPrefix ]]; then
buildArgs="--out-link $outLinkPrefix-$scenario"
else
buildArgs=--no-out-link
fi
vmTestNixExpr | nix-build $buildArgs "$@" -
} }
# On continuous integration nodes there are few other processes running alongside the # On continuous integration nodes there are few other processes running alongside the