git.iko.soy/typeable/nixpkgs
on master help sign in
nixos: nixos/doc/manual/development/running-nixos-tests-interactively.xml to CommonMark
commit47fe2c7e935b03e7788f4db1935b0527af370a09 authorBobby Rong <rjl931189261@126.com> dateFri 2 Jul 2021, 20:24 (5 years ago) parent8fafcfa
4 files changed+95−50
nixos/doc/manual/development/nixos-tests.xml+1−1 nixos/doc/manual/development/running-nixos-tests-interactively.section.md+44 nixos/doc/manual/development/running-nixos-tests-interactively.xml−49 nixos/doc/manual/from_md/development/running-nixos-tests-interactively.section.xml+50
nixos/doc/manual/development/nixos-tests.xml+1−1
@@ -15,5 +15,5 @@ xlink:href="https://github.com/NixOS/nixpkgs/tree/master/nixos/tests">nixos/test
1515 </para>
1616 <xi:include href="../from_md/development/writing-nixos-tests.section.xml" />
1717 <xi:include href="../from_md/development/running-nixos-tests.section.xml" />
18− <xi:include href="running-nixos-tests-interactively.xml" />
18+ <xi:include href="../from_md/development/running-nixos-tests-interactively.section.xml" />
1919</chapter>
nixos/doc/manual/development/running-nixos-tests-interactively.section.mdnew file+44
@@ -0,0 +1,44 @@
1+# Running Tests interactively {#sec-running-nixos-tests-interactively}
2+
3+The test itself can be run interactively. This is particularly useful
4+when developing or debugging a test:
5+
6+```ShellSession
7+$ nix-build nixos/tests/login.nix -A driverInteractive
8+$ ./result/bin/nixos-test-driver
9+starting VDE switch for network 1
10+>
11+```
12+
13+You can then take any Python statement, e.g.
14+
15+```py
16+> start_all()
17+> test_script()
18+> machine.succeed("touch /tmp/foo")
19+> print(machine.succeed("pwd")) # Show stdout of command
20+```
21+
22+The function `test_script` executes the entire test script and drops you
23+back into the test driver command line upon its completion. This allows
24+you to inspect the state of the VMs after the test (e.g. to debug the
25+test script).
26+
27+To just start and experiment with the VMs, run:
28+
29+```ShellSession
30+$ nix-build nixos/tests/login.nix -A driverInteractive
31+$ ./result/bin/nixos-run-vms
32+```
33+
34+The script `nixos-run-vms` starts the virtual machines defined by test.
35+
36+You can re-use the VM states coming from a previous run by setting the
37+`--keep-vm-state` flag.
38+
39+```ShellSession
40+$ ./result/bin/nixos-run-vms --keep-vm-state
41+```
42+
43+The machine state is stored in the `$TMPDIR/vm-state-machinename`
44+directory.
nixos/doc/manual/development/running-nixos-tests-interactively.xmldeleted−49
@@ -1,49 +0,0 @@
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− <title>Running Tests interactively</title>
7−
8− <para>
9− The test itself can be run interactively. This is particularly useful when
10− developing or debugging a test:
11−<screen>
12−<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
13−<prompt>$ </prompt>./result/bin/nixos-test-driver
14−starting VDE switch for network 1
15−<prompt>&gt;</prompt>
16−</screen>
17− You can then take any Python statement, e.g.
18−<screen>
19−<prompt>&gt;</prompt> start_all()
20−<prompt>&gt;</prompt> test_script()
21−<prompt>&gt;</prompt> machine.succeed("touch /tmp/foo")
22−<prompt>&gt;</prompt> print(machine.succeed("pwd")) # Show stdout of command
23−</screen>
24− The function <command>test_script</command> executes the entire test script
25− and drops you back into the test driver command line upon its completion.
26− This allows you to inspect the state of the VMs after the test (e.g. to debug
27− the test script).
28− </para>
29−
30− <para>
31− To just start and experiment with the VMs, run:
32−<screen>
33−<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
34−<prompt>$ </prompt>./result/bin/nixos-run-vms
35−</screen>
36− The script <command>nixos-run-vms</command> starts the virtual machines
37− defined by test.
38− </para>
39−
40− <para>
41− You can re-use the VM states coming from a previous run
42− by setting the <command>--keep-vm-state</command> flag.
43−<screen>
44−<prompt>$ </prompt>./result/bin/nixos-run-vms --keep-vm-state
45−</screen>
46− The machine state is stored in the
47− <filename>$TMPDIR/vm-state-</filename><varname>machinename</varname> directory.
48− </para>
49−</section>
nixos/doc/manual/from_md/development/running-nixos-tests-interactively.section.xmlnew file+50
@@ -0,0 +1,50 @@
1+<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-running-nixos-tests-interactively">
2+ <title>Running Tests interactively</title>
3+ <para>
4+ The test itself can be run interactively. This is particularly
5+ useful when developing or debugging a test:
6+ </para>
7+ <programlisting>
8+$ nix-build nixos/tests/login.nix -A driverInteractive
9+$ ./result/bin/nixos-test-driver
10+starting VDE switch for network 1
11+&gt;
12+</programlisting>
13+ <para>
14+ You can then take any Python statement, e.g.
15+ </para>
16+ <programlisting language="python">
17+&gt; start_all()
18+&gt; test_script()
19+&gt; machine.succeed(&quot;touch /tmp/foo&quot;)
20+&gt; print(machine.succeed(&quot;pwd&quot;)) # Show stdout of command
21+</programlisting>
22+ <para>
23+ The function <literal>test_script</literal> executes the entire test
24+ script and drops you back into the test driver command line upon its
25+ completion. This allows you to inspect the state of the VMs after
26+ the test (e.g. to debug the test script).
27+ </para>
28+ <para>
29+ To just start and experiment with the VMs, run:
30+ </para>
31+ <programlisting>
32+$ nix-build nixos/tests/login.nix -A driverInteractive
33+$ ./result/bin/nixos-run-vms
34+</programlisting>
35+ <para>
36+ The script <literal>nixos-run-vms</literal> starts the virtual
37+ machines defined by test.
38+ </para>
39+ <para>
40+ You can re-use the VM states coming from a previous run by setting
41+ the <literal>--keep-vm-state</literal> flag.
42+ </para>
43+ <programlisting>
44+$ ./result/bin/nixos-run-vms --keep-vm-state
45+</programlisting>
46+ <para>
47+ The machine state is stored in the
48+ <literal>$TMPDIR/vm-state-machinename</literal> directory.
49+ </para>
50+</section>