diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index cdaed5fa514c..fd34fe23d767 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -26,7 +26,6 @@ rec { extraTestModule = { config = { hostPkgs = pkgs; - minimalResult = hydra; }; }; diff --git a/nixos/lib/testing/run.nix b/nixos/lib/testing/run.nix index 65bcbe720bf3..cc31914f745d 100644 --- a/nixos/lib/testing/run.nix +++ b/nixos/lib/testing/run.nix @@ -16,22 +16,22 @@ in ''; }; - run = mkOption { + test = mkOption { type = types.package; description = '' - Derivation that runs the test. + Derivation that runs the test as its "build" process. ''; }; }; config = { - run = hostPkgs.stdenv.mkDerivation { - name = "vm-test-run-${config.name}"; + test = lib.lazyDerivation { # lazyDerivation improves performance when only passthru items and/or meta are used. + derivation = hostPkgs.stdenv.mkDerivation { + name = "vm-test-run-${config.name}"; - requiredSystemFeatures = [ "kvm" "nixos-test" ]; + requiredSystemFeatures = [ "kvm" "nixos-test" ]; - buildCommand = - '' + buildCommand = '' mkdir -p $out # effectively mute the XMLLogger @@ -40,9 +40,11 @@ in ${config.driver}/bin/nixos-test-driver -o $out ''; - passthru = config.passthru; + passthru = config.passthru; - meta = config.meta; + meta = config.meta; + }; + inherit (config) passthru meta; }; # useful for inspection (debugging / exploration) diff --git a/nixos/release.nix b/nixos/release.nix index f70b02c4292b..4f27e5dbb215 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -22,8 +22,8 @@ let import ./tests/all-tests.nix { inherit system; pkgs = import ./.. { inherit system; }; - callTest = t: { - ${system} = hydraJob t.test; + callTest = config: { + ${system} = hydraJob config.test; }; } // { # for typechecking of the scripts and evaluation of @@ -32,8 +32,8 @@ let import ./tests/all-tests.nix { inherit system; pkgs = import ./.. { inherit system; }; - callTest = t: { - ${system} = hydraJob t.test.driver; + callTest = config: { + ${system} = hydraJob config.driver; }; }; }; diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 5cd58cb5c3fd..62e05fcf2b1e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1,4 +1,11 @@ -{ system, pkgs, callTest }: +{ system, + pkgs, + + # Projects the test configuration into a the desired value; usually + # the test runner: `config: config.test`. + callTest, + +}: # The return value of this function will be an attrset with arbitrary depth and # the `anything` returned by callTest at its test leafs. # The tests not supported by `system` will be replaced with `{}`, so that @@ -29,11 +36,17 @@ let inherit (rec { - doRunTest = (import ../lib/testing-python.nix { inherit system pkgs; }).runTest; + doRunTest = arg: (import ../lib/testing-python.nix { inherit system pkgs; }).runTest { + imports = [ arg { inherit callTest; } ]; + }; findTests = tree: if tree?recurseForDerivations && tree.recurseForDerivations - then mapAttrs (k: findTests) (builtins.removeAttrs tree ["recurseForDerivations"]) - else callTest ({ test = tree; }); + then + mapAttrs + (k: findTests) + (builtins.removeAttrs tree ["recurseForDerivations"]) + else callTest tree; + runTest = arg: let r = doRunTest arg; in findTests r; runTestOn = systems: arg: if elem system systems then runTest arg diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ec53eedd77ff..d369fafdcc49 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -140,14 +140,14 @@ with pkgs; nixosTests = import ../../nixos/tests/all-tests.nix { inherit pkgs; system = stdenv.hostPlatform.system; - callTest = t: t.test; + callTest = config: config.test; } // { # for typechecking of the scripts and evaluation of # the nodes, without running VMs. allDrivers = import ../../nixos/tests/all-tests.nix { inherit pkgs; system = stdenv.hostPlatform.system; - callTest = t: t.test.driver; + callTest = config: config.test.driver; }; };