2014-08-24 18:18:18 +01:00
|
|
|
|
<section xmlns="http://docbook.org/ns/docbook"
|
|
|
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
|
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
|
version="5.0"
|
2019-11-17 10:47:28 +00:00
|
|
|
|
xml:id="sec-running-nixos-tests">
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<title>Running Tests</title>
|
2014-08-24 18:18:18 +01:00
|
|
|
|
|
2018-05-02 00:57:09 +01:00
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
You can run tests using <command>nix-build</command>. For example, to run the
|
|
|
|
|
test
|
|
|
|
|
<filename
|
|
|
|
|
xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/login.nix">login.nix</filename>,
|
|
|
|
|
you just do:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<screen>
|
2019-06-17 12:25:50 +01:00
|
|
|
|
<prompt>$ </prompt>nix-build '<nixpkgs/nixos/tests/login.nix>'
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</screen>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
or, if you don’t want to rely on <envar>NIX_PATH</envar>:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<screen>
|
2019-06-17 12:25:50 +01:00
|
|
|
|
<prompt>$ </prompt>cd /my/nixpkgs/nixos/tests
|
|
|
|
|
<prompt>$ </prompt>nix-build login.nix
|
2014-08-24 18:18:18 +01:00
|
|
|
|
…
|
|
|
|
|
running the VM test script
|
|
|
|
|
machine: QEMU running (pid 8841)
|
|
|
|
|
…
|
|
|
|
|
6 out of 6 tests succeeded
|
|
|
|
|
</screen>
|
2019-09-19 18:17:30 +01:00
|
|
|
|
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
|
|
|
|
|
pretty-printed log of the test:
|
2014-08-24 18:18:18 +01:00
|
|
|
|
<screen>
|
2019-06-17 12:25:50 +01:00
|
|
|
|
<prompt>$ </prompt>firefox result/log.html
|
2014-08-24 18:18:18 +01:00
|
|
|
|
</screen>
|
2018-05-02 00:57:09 +01:00
|
|
|
|
</para>
|
2014-11-27 18:01:34 +00:00
|
|
|
|
</section>
|