mirror of
https://github.com/fort-nix/nix-bitcoin.git
synced 2024-11-27 02:12:45 +03:00
edbaeb9813
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.
31 lines
737 B
Bash
31 lines
737 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# This script uses the following env vars:
|
|
# NIX_BITCOIN_VM_ENABLE_NETWORK
|
|
# NIX_BITCOIN_VM_DATADIR
|
|
# QEMU_OPTS
|
|
# QEMU_NET_OPTS
|
|
|
|
if [[ ${NIX_BITCOIN_VM_DATADIR:-} ]]; then
|
|
dataDir=$NIX_BITCOIN_VM_DATADIR
|
|
else
|
|
dataDir=$(mktemp -d /tmp/nix-bitcoin-vm.XXX)
|
|
trap 'rm -rf "$dataDir"' EXIT
|
|
fi
|
|
|
|
if [[ ! ${NIX_BITCOIN_VM_ENABLE_NETWORK:-} ]]; then
|
|
QEMU_NET_OPTS='restrict=on'
|
|
fi
|
|
|
|
# TODO-EXTERNAL:
|
|
# Pass PATH because run-*-vm is impure (requires coreutils from PATH)
|
|
env -i \
|
|
PATH="$PATH" \
|
|
USE_TMPDIR=1 \
|
|
TMPDIR="$dataDir" \
|
|
NIX_DISK_IMAGE="$dataDir/img.qcow2" \
|
|
QEMU_OPTS="${QEMU_OPTS:-}" \
|
|
QEMU_NET_OPTS="${QEMU_NET_OPTS:-}" \
|
|
"${BASH_SOURCE[0]%/*}"/run-*-vm
|