about summary refs log tree commit diff
path: root/doc/builders
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-04-08 18:44:24 +0200
committerRobert Hensing <robert@roberthensing.nl>2023-05-11 19:12:07 +0200
commitac1134f321b60f9e27ab0d973a4544480acc0709 (patch)
treea230021e64c96e90ecaff2fa6b9fa51f6692caab /doc/builders
parent6948ef4deff7a72ebe5242244bd3730e8542b925 (diff)
testers.runNixOSTest: init
An up to date alternative to pkgs.nixosTest
Diffstat (limited to 'doc/builders')
-rw-r--r--doc/builders/testers.chapter.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/doc/builders/testers.chapter.md b/doc/builders/testers.chapter.md
index a644262fd9c92..928a57673e770 100644
--- a/doc/builders/testers.chapter.md
+++ b/doc/builders/testers.chapter.md
@@ -164,6 +164,26 @@ tests.fetchgit = testers.invalidateFetcherByDrvHash fetchgit {
 };
 ```
 
+## `runNixOSTest` {#tester-runNixOSTest}
+
+A helper function that behaves exactly like the NixOS `runTest`, except it also assigns this Nixpkgs package set as the `pkgs` of the test and makes the `nixpkgs.*` options read-only.
+
+If your test is part of the Nixpkgs repository, or if you need a more general entrypoint, see ["Calling a test" in the NixOS manual](https://nixos.org/manual/nixos/stable/index.html#sec-calling-nixos-tests).
+
+Example:
+
+```nix
+pkgs.testers.runNixOSTest ({ lib, ... }: {
+  name = "hello";
+  nodes.machine = { pkgs, ... }: {
+    environment.systemPackages = [ pkgs.hello ];
+  };
+  testScript = ''
+    machine.succeed("hello")
+  '';
+})
+```
+
 ## `nixosTest` {#tester-nixosTest}
 
 Run a NixOS VM network test using this evaluation of Nixpkgs.