about summary refs log tree commit diff
path: root/pkgs/build-support
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 /pkgs/build-support
parentae172a2bb4c94da68fb0adfd77d5aacd71c8b930 (diff)
tests.testers.nixosTest-example: move from tests.nixos-functions.nixosTest-test
And improve the test a bit, to assert correct wiring of `pkgs`.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/testers/test/README.md8
-rw-r--r--pkgs/build-support/testers/test/default.nix27
2 files changed, 35 insertions, 0 deletions
diff --git a/pkgs/build-support/testers/test/README.md b/pkgs/build-support/testers/test/README.md
new file mode 100644
index 0000000000000..2d6b4bdc43fea
--- /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 0000000000000..30e778cf652ea
--- /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")
+    '';
+  });
+}