Unverified Commit 4147e7d4 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge master into staging-next

parents 03ea42ab b3832917
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -17,9 +17,9 @@ trap "rm ${tmpfile}" 0

echo "Remember that you need to manually run 'maintainers/scripts/haskell/hydra-report.hs get-report' sometime before running this script."
echo "Generating a list of broken builds and displaying for manual confirmation ..."
maintainers/scripts/haskell/hydra-report.hs mark-broken-list | sort -i > $tmpfile
maintainers/scripts/haskell/hydra-report.hs mark-broken-list | sort -i > "$tmpfile"

$EDITOR $tmpfile
$EDITOR "$tmpfile"

tail -n +3 "$broken_config" >> "$tmpfile"

@@ -28,10 +28,11 @@ broken-packages:
  # These packages don't compile.
EOF

# clear environment here to avoid things like allowing broken builds in
sort -iu "$tmpfile" >> "$broken_config"
maintainers/scripts/haskell/regenerate-hackage-packages.sh
maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
maintainers/scripts/haskell/regenerate-hackage-packages.sh
env -i maintainers/scripts/haskell/regenerate-hackage-packages.sh
env -i maintainers/scripts/haskell/regenerate-transitive-broken-packages.sh
env -i maintainers/scripts/haskell/regenerate-hackage-packages.sh

if [[ "${1:-}" == "--do-commit" ]]; then
git add $broken_config
+3 −3
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/tests">nixos/test
  one or more virtual machines containing the NixOS system(s) required for the
  test.
 </para>
 <xi:include href="writing-nixos-tests.xml" />
 <xi:include href="running-nixos-tests.xml" />
 <xi:include href="running-nixos-tests-interactively.xml" />
 <xi:include href="../from_md/development/writing-nixos-tests.section.xml" />
 <xi:include href="../from_md/development/running-nixos-tests.section.xml" />
 <xi:include href="../from_md/development/running-nixos-tests-interactively.section.xml" />
</chapter>
+44 −0
Original line number Diff line number Diff line
# Running Tests interactively {#sec-running-nixos-tests-interactively}

The test itself can be run interactively. This is particularly useful
when developing or debugging a test:

```ShellSession
$ nix-build nixos/tests/login.nix -A driverInteractive
$ ./result/bin/nixos-test-driver
starting VDE switch for network 1
>
```

You can then take any Python statement, e.g.

```py
> start_all()
> test_script()
> machine.succeed("touch /tmp/foo")
> print(machine.succeed("pwd")) # Show stdout of command
```

The function `test_script` executes the entire test script and drops you
back into the test driver command line upon its completion. This allows
you to inspect the state of the VMs after the test (e.g. to debug the
test script).

To just start and experiment with the VMs, run:

```ShellSession
$ nix-build nixos/tests/login.nix -A driverInteractive
$ ./result/bin/nixos-run-vms
```

The script `nixos-run-vms` starts the virtual machines defined by test.

You can re-use the VM states coming from a previous run by setting the
`--keep-vm-state` flag.

```ShellSession
$ ./result/bin/nixos-run-vms --keep-vm-state
```

The machine state is stored in the `$TMPDIR/vm-state-machinename`
directory.
+0 −49
Original line number Diff line number Diff line
<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"
        xml:id="sec-running-nixos-tests-interactively">
 <title>Running Tests interactively</title>

 <para>
  The test itself can be run interactively. This is particularly useful when
  developing or debugging a test:
<screen>
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
<prompt>$ </prompt>./result/bin/nixos-test-driver
starting VDE switch for network 1
<prompt>&gt;</prompt>
</screen>
  You can then take any Python statement, e.g.
<screen>
<prompt>&gt;</prompt> start_all()
<prompt>&gt;</prompt> test_script()
<prompt>&gt;</prompt> machine.succeed("touch /tmp/foo")
<prompt>&gt;</prompt> print(machine.succeed("pwd")) # Show stdout of command
</screen>
  The function <command>test_script</command> executes the entire test script
  and drops you back into the test driver command line upon its completion.
  This allows you to inspect the state of the VMs after the test (e.g. to debug
  the test script).
 </para>

 <para>
  To just start and experiment with the VMs, run:
<screen>
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
<prompt>$ </prompt>./result/bin/nixos-run-vms
</screen>
  The script <command>nixos-run-vms</command> starts the virtual machines
  defined by test.
 </para>

 <para>
   You can re-use the VM states coming from a previous run
   by setting the <command>--keep-vm-state</command> flag.
<screen>
<prompt>$ </prompt>./result/bin/nixos-run-vms --keep-vm-state
</screen>
  The machine state is stored in the
  <filename>$TMPDIR/vm-state-</filename><varname>machinename</varname> directory.
 </para>
</section>
+31 −0
Original line number Diff line number Diff line
# 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),
you just do:

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

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

```ShellSession
$ 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 pretty-printed log of the test:

```ShellSession
$ firefox result/log.html
```
Loading