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:
Erik Arvstedt 2022-10-22 19:37:58 +02:00
parent 90e942e5ae
commit edbaeb9813
No known key found for this signature in database
GPG key ID: 33312B944DD97846
12 changed files with 451 additions and 277 deletions

View file

@ -8,9 +8,14 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
extra-container = {
url = "github:erikarvstedt/extra-container";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils }:
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, ... }:
let
supportedSystems = [
"x86_64-linux"
@ -18,6 +23,8 @@
"aarch64-linux"
"armv7l-linux"
];
test = import ./test/tests.nix nixpkgs.lib;
in {
lib = {
mkNbPkgs = {
@ -27,6 +34,10 @@
}:
import ./pkgs { inherit pkgs pkgsUnstable; };
test = {
inherit (test) scenarios;
};
inherit supportedSystems;
};
@ -93,7 +104,12 @@
# Allow accessing the whole nested `nbPkgs` attrset (including `modulesPkgs`)
# via this flake.
# `packages` is not allowed to contain nested pkgs attrsets.
legacyPackages = nbPkgs;
legacyPackages =
nbPkgs //
(test.pkgs self pkgs) //
{
extra-container = self.inputs.extra-container.packages.${system}.default;
};
apps = rec {
default = vm;