summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-05-09 14:18:40 +0200
committerRobert Hensing <robert@roberthensing.nl>2022-05-09 14:21:56 +0200
commit93abb7bef7a73f0c5fa0453d60c024ca7464f1c5 (patch)
tree57693c87cfff322ca35117d00a90ebe1a8333058
parentae172a2bb4c94da68fb0adfd77d5aacd71c8b930 (diff)
downloadnixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.tar
nixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.tar.gz
nixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.tar.bz2
nixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.tar.lz
nixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.tar.xz
nixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.tar.zst
nixpkgs-93abb7bef7a73f0c5fa0453d60c024ca7464f1c5.zip
tests.testers.nixosTest-example: move from tests.nixos-functions.nixosTest-test
And improve the test a bit, to assert correct wiring of `pkgs`.
-rw-r--r--pkgs/build-support/testers/test/README.md8
-rw-r--r--pkgs/build-support/testers/test/default.nix27
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/test/nixos-functions/default.nix11
4 files changed, 37 insertions, 11 deletions
diff --git a/pkgs/build-support/testers/test/README.md b/pkgs/build-support/testers/test/README.md
new file mode 100644
index 00000000000..2d6b4bdc43f
--- /dev/null
+++ b/pkgs/build-support/testers/test/README.md
@@ -0,0 +1,8 @@
+# Tests _for the testers_
+
+    cd nixpkgs
+    nix-build -A tests.testers
+
+Tests generally derive their own correctness from simplicity, which in the
+case of testers (themselves functions) does not always work out.
+Hence the need for tests that test the testers.
diff --git a/pkgs/build-support/testers/test/default.nix b/pkgs/build-support/testers/test/default.nix
new file mode 100644
index 00000000000..30e778cf652
--- /dev/null
+++ b/pkgs/build-support/testers/test/default.nix
@@ -0,0 +1,27 @@
+{ testers, lib, pkgs, ... }:
+let
+  pkgs-with-overlay = pkgs.extend(final: prev: {
+    proof-of-overlay-hello = prev.hello;
+  });
+
+  dummyVersioning = {
+    revision = "test";
+    versionSuffix = "test";
+    label = "test";
+  };
+
+in
+lib.recurseIntoAttrs {
+  # Check that the wiring of nixosTest is correct.
+  # Correct operation of the NixOS test driver should be asserted elsewhere.
+  nixosTest-example = pkgs-with-overlay.testers.nixosTest ({ lib, pkgs, figlet, ... }: {
+    name = "nixosTest-test";
+    nodes.machine = { pkgs, ... }: {
+      system.nixos = dummyVersioning;
+      environment.systemPackages = [ pkgs.proof-of-overlay-hello figlet ];
+    };
+    testScript = ''
+      machine.succeed("hello | figlet >/dev/console")
+    '';
+  });
+}
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 63aaf6bb72e..2ab03bda8b7 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -67,6 +67,8 @@ with pkgs;
 
   writers = callPackage ../build-support/writers/test.nix {};
 
+  testers = callPackage ../build-support/testers/test/default.nix {};
+
   dhall = callPackage ./dhall { };
 
   makeWrapper = callPackage ./make-wrapper {};
diff --git a/pkgs/test/nixos-functions/default.nix b/pkgs/test/nixos-functions/default.nix
index 6f83858d01a..1e4b8d905e5 100644
--- a/pkgs/test/nixos-functions/default.nix
+++ b/pkgs/test/nixos-functions/default.nix
@@ -26,16 +26,5 @@ in lib.optionalAttrs stdenv.hostPlatform.isLinux (
       fileSystems."/".device = "/dev/null";
     }).toplevel;
 
-    nixosTest-test = pkgs.testers.nixosTest ({ lib, pkgs, figlet, ... }: {
-      name = "nixosTest-test";
-      nodes.machine = { pkgs, ... }: {
-        system.nixos = dummyVersioning;
-        environment.systemPackages = [ pkgs.hello figlet ];
-      };
-      testScript = ''
-        machine.succeed("hello | figlet >/dev/console")
-      '';
-    });
-
   }
 )