From 0295ad1904fb12ae0406cbc46b8a023d128c0b23 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 7 Jul 2025 19:33:29 +0200 Subject: [PATCH 1/2] nixos/all-tests: Use ? in discoverTests Exactly equivalent --- 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 d370a4180286..0b9b4b095e9d 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -21,7 +21,7 @@ let discoverTests = val: if isAttrs val then - if hasAttr "test" val then + if (val ? test) then callTest val else mapAttrs (n: s: if n == "passthru" then s else discoverTests s) val From 0e326612020a266215f96b1aaf8d5a5d97f39b2f Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 7 Jul 2025 19:46:37 +0200 Subject: [PATCH 2/2] nixos/testing: Add test attribute to please discoverTests --- nixos/lib/testing/run.nix | 5 +++++ nixos/tests/all-tests.nix | 2 ++ 2 files changed, 7 insertions(+) diff --git a/nixos/lib/testing/run.nix b/nixos/lib/testing/run.nix index 752c1e911803..45ab311cfbc4 100644 --- a/nixos/lib/testing/run.nix +++ b/nixos/lib/testing/run.nix @@ -106,6 +106,11 @@ in # useful for inspection (debugging / exploration) passthru.config = config; + /** + For discoverTests only. Deprecated. Will be removed when discoverTests can be removed from NixOS all-tests.nix. + */ + passthru.test = config.test; + # Docs: nixos/doc/manual/development/writing-nixos-tests.section.md /** See https://nixos.org/manual/nixos/unstable#sec-override-nixos-test diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 0b9b4b095e9d..4fd1c64693ac 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -18,6 +18,8 @@ with pkgs.lib; let + # TODO: remove when handleTest is gone (make sure nixosTests and nixos/release.nix#tests are unaffected) + # TODO: when removing, also deprecate `test` attribute in ../lib/testing/run.nix discoverTests = val: if isAttrs val then