2021-07-02 12:23:38 +00:00
|
|
|
# Running Tests {#sec-running-nixos-tests}
|
|
|
|
|
|
|
|
You can run tests using `nix-build`. For example, to run the test
|
|
|
|
[`login.nix`](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/login.nix),
|
2022-06-15 16:05:48 +00:00
|
|
|
you do:
|
2021-07-02 12:23:38 +00:00
|
|
|
|
|
|
|
```ShellSession
|
2022-06-15 16:05:48 +00:00
|
|
|
$ cd /my/git/clone/of/nixpkgs
|
|
|
|
$ nix-build -A nixosTests.login
|
2021-07-02 12:23:38 +00: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,
|
2022-01-12 01:43:08 +00:00
|
|
|
you can view a log of the test:
|
2021-07-02 12:23:38 +00:00
|
|
|
|
|
|
|
```ShellSession
|
2022-01-12 01:43:08 +00:00
|
|
|
$ nix-store --read-log result
|
2021-07-02 12:23:38 +00:00
|
|
|
```
|