1<section xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:xi="http://www.w3.org/2001/XInclude"
4 version="5.0"
5 xml:id="sec-running-nixos-tests-interactively">
6
7<title>Running Tests</title>
8
9<para>You can run tests using <command>nix-build</command>. For
10example, to run the test <filename
11xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/login.nix">login.nix</filename>,
12you just do:
13
14<screen>
15$ nix-build '<nixpkgs/nixos/tests/login.nix>'
16</screen>
17
18or, if you don’t want to rely on <envar>NIX_PATH</envar>:
19
20<screen>
21$ cd /my/nixpkgs/nixos/tests
22$ nix-build login.nix
23…
24running the VM test script
25machine: QEMU running (pid 8841)
26…
276 out of 6 tests succeeded
28</screen>
29
30After building/downloading all required dependencies, this will
31perform a build that starts a QEMU/KVM virtual machine containing a
32NixOS system. The virtual machine mounts the Nix store of the host;
33this makes VM creation very fast, as no disk image needs to be
34created. Afterwards, you can view a pretty-printed log of the test:
35
36<screen>
37$ firefox result/log.html
38</screen>
39
40</para>
41</section>