From 2e5b287bc8efe36dac2eed9559c0160db536bf06 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Sun, 18 Dec 2022 13:13:44 +0100 Subject: [PATCH] test: update to NixOS 22.11 --- test/lib/make-test-vm.nix | 23 ++++++++++++++--------- test/lib/make-test.nix | 2 +- test/tests.py | 3 ++- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/test/lib/make-test-vm.nix b/test/lib/make-test-vm.nix index 43f89bf..f5abd98 100644 --- a/test/lib/make-test-vm.nix +++ b/test/lib/make-test-vm.nix @@ -6,20 +6,25 @@ let }; in -args: +module: let - test = pythonTesting.makeTest args; + test = (pythonTesting.evalTest module).config; - # 1. Save test logging output - # 2. Add link to driver so that a gcroot to a test prevents the driver from - # being garbage-collected - fixedTest = test.overrideAttrs (_: { - # See `runTests` in nixpkgs/nixos/lib/testing-python.nix for the original definition of `buildCommand` + 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" ''; - }); + + inherit (test) meta passthru; + } // test; in - fixedTest + runTest diff --git a/test/lib/make-test.nix b/test/lib/make-test.nix index 3c0a502..dd212d4 100644 --- a/test/lib/make-test.nix +++ b/test/lib/make-test.nix @@ -47,7 +47,7 @@ let # is_interactive is set in ./run-vm.sh '' if not "is_interactive" in vars(): - run_tests() + nb_run_tests() '' ]; }; diff --git a/test/tests.py b/test/tests.py index 1fb98e2..d43f801 100644 --- a/test/tests.py +++ b/test/tests.py @@ -48,7 +48,8 @@ def test(name): tests[name] = fn return x -def run_tests(): +# `run_tests` is already defined by the NixOS test driver +def nb_run_tests(): enabled = enabled_tests.copy() to_run = [] for test in tests: