From 6229f0bc8f4ae4c988e9d76937e0aaedea067de4 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sun, 6 Aug 2023 15:40:10 +0200 Subject: [PATCH 1/2] all-tests: exclude passthru attributes from test discovery discoverTests tries to discover some sort of internal function and tries to call it with the arguments for that internal function. This poses an issue when you want to expose some other functions (i.e. a parameterisation for a test) in nixosTests. This commit allows a test to pass through arbitrary values via `.passthru` without them having discovery applied to them; including functions. --- nixos/tests/all-tests.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 3b4a39f5ff96..70548ebe55d8 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -21,7 +21,7 @@ let if isAttrs val then if hasAttr "test" val then callTest val - else mapAttrs (n: s: discoverTests s) val + else mapAttrs (n: s: if n == "passthru" then s else discoverTests s) val else if isFunction val then # Tests based on make-test-python.nix will return the second lambda From a0dcabb6907f00677af78a12fa90ff73bed31061 Mon Sep 17 00:00:00 2001 From: Atemu Date: Sun, 6 Aug 2023 15:45:09 +0200 Subject: [PATCH 2/2] kernel: fix passthru.tests https://github.com/NixOS/nixpkgs/pull/191540 indirectly broke kernel passthru.tests; calling the testsForLinuxPackages and testsForKernel functions with some args intended for some other exposed test-internal function. Organise the passed-through functions under `passthru` to prevent this from happening. --- nixos/tests/kernel-generic.nix | 6 ++++-- pkgs/os-specific/linux/kernel/generic.nix | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nixos/tests/kernel-generic.nix b/nixos/tests/kernel-generic.nix index e4a8e06df1ef..e69dd550289c 100644 --- a/nixos/tests/kernel-generic.nix +++ b/nixos/tests/kernel-generic.nix @@ -42,7 +42,9 @@ let }; in mapAttrs (_: lP: testsForLinuxPackages lP) kernels // { - inherit testsForLinuxPackages; + passthru = { + inherit testsForLinuxPackages; - testsForKernel = kernel: testsForLinuxPackages (pkgs.linuxPackagesFor kernel); + testsForKernel = kernel: testsForLinuxPackages (pkgs.linuxPackagesFor kernel); + }; } diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 660521349053..ade256802d6e 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -220,7 +220,7 @@ let + toString (lib.attrNames (if lib.isAttrs args then args else args {})) ) overridableKernel; }; - in [ (nixosTests.kernel-generic.testsForKernel overridableKernel) ] ++ kernelTests; + in [ (nixosTests.kernel-generic.passthru.testsForKernel overridableKernel) ] ++ kernelTests; }; finalKernel = lib.extendDerivation true passthru kernel;