depot/third_party/nixpkgs/nixos/doc/manual/development/running-nixos-tests.section.md
Default email 871149a62e Project import generated by Copybara.
GitOrigin-RevId: 7f9b6e2babf232412682c09e57ed666d8f84ac2d
2022-02-21 09:47:16 +01:00

854 B

Running Tests

You can run tests using nix-build. For example, to run the test login.nix, you just do:

$ nix-build '<nixpkgs/nixos/tests/login.nix>'

or, if you don't want to rely on NIX_PATH:

$ cd /my/nixpkgs/nixos/tests
$ nix-build login.nix
…
running the VM test script
machine: QEMU running (pid 8841)
…
6 out of 6 tests succeeded

After building/downloading all required dependencies, this will perform a build that starts a QEMU/KVM virtual machine containing a NixOS system. The virtual machine mounts the Nix store of the host; this makes VM creation very fast, as no disk image needs to be created. Afterwards, you can view a log of the test:

$ nix-store --read-log result