nix-bitcoin/test/lib/make-test-vm.nix

31 lines
755 B
Nix
Raw Normal View History

pkgs:
let
pythonTesting = import (pkgs.path + "/nixos/lib/testing-python.nix") {
system = pkgs.stdenv.hostPlatform.system;
inherit pkgs;
};
in
2022-12-18 04:13:44 -08:00
module:
let
2022-12-18 04:13:44 -08:00
test = (pythonTesting.evalTest module).config;
2022-12-18 04:13:44 -08:00
runTest = pkgs.stdenv.mkDerivation {
name = "vm-test-run-${test.name}";
requiredSystemFeatures = [ "kvm" "nixos-test" ];
# 1. Save test logging output
# 2. Add link to driver so that a gcroot to a test prevents the driver from
# being garbage-collected
buildCommand = ''
mkdir "$out"
LOGFILE=$out/output.xml tests='exec(os.environ["testScript"])' ${test.driver}/bin/nixos-test-driver
ln -s ${test.driver} "$out/driver"
'';
2022-12-18 04:13:44 -08:00
inherit (test) meta passthru;
} // test;
in
2022-12-18 04:13:44 -08:00
runTest