tests: define tests via flake
Advantages: - Pure test evaluations - The test framework can now be used by flakes that extend nix-bitcoin - Most features of `run-tests.sh` are now accessible via `nix build`/`nix run`. We keep `run-tests.sh` for advanced features like `scenarioOverridesFile` and adhoc scenarios. Other changes: - `run-tests.sh` now builds aggregate VM tests like `basic` or `buildable` by creating all VMs in a single evaluation. This speeds up the tests and eases debugging by separating the eval and build steps. - Use the new `nix` CLI which has improved build output logging by prefixing output lines with the origin drv name.
This commit is contained in:
@@ -53,7 +53,10 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export containerName=nb-test
|
||||
# These vars are set by ../run-tests.sh
|
||||
: "${container:=}"
|
||||
: "${scriptDir:=}"
|
||||
|
||||
containerCommand=shell
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
@@ -69,11 +72,10 @@ while [[ $# -gt 0 ]]; do
|
||||
done
|
||||
|
||||
containerBin=$(type -P extra-container) || true
|
||||
if [[ ! ($containerBin && $(realpath "$containerBin") == *extra-container-0.10*) ]]; then
|
||||
if [[ ! ($containerBin && $(realpath "$containerBin") == *extra-container-0.11*) ]]; then
|
||||
echo
|
||||
echo "Building extra-container. Skip this step by adding extra-container 0.10 to PATH."
|
||||
nix-build --out-link /tmp/extra-container "$scriptDir"/../pkgs \
|
||||
-A pinned.extra-container >/dev/null
|
||||
echo "Building extra-container. Skip this step by adding extra-container 0.11 to PATH."
|
||||
nix build --out-link /tmp/extra-container "$scriptDir"/..#extra-container
|
||||
# When this script is run as root, e.g. when run in an extra-container shell,
|
||||
# chown the gcroot symlink to the regular (login) user so that the symlink can be
|
||||
# overwritten when this script is run without root.
|
||||
@@ -83,7 +85,4 @@ if [[ ! ($containerBin && $(realpath "$containerBin") == *extra-container-0.10*)
|
||||
export PATH="/tmp/extra-container/bin${PATH:+:}$PATH"
|
||||
fi
|
||||
|
||||
read -rd '' src <<EOF || true
|
||||
((import "$scriptDir/tests.nix" {}).getTest "$scenario").container
|
||||
EOF
|
||||
exec extra-container "$containerCommand" -E "$src" "$@"
|
||||
exec "$container"/bin/container "$containerCommand" "$@"
|
||||
|
||||
Reference in New Issue
Block a user