Merge pull request #153273 from Synthetica9/passthru-driverInteractive

This commit is contained in:
Patrick Hilhorst 2022-01-07 16:04:43 +01:00 committed by GitHub
commit 0c3f1cf420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 17 deletions

View File

@ -4,19 +4,19 @@ The test itself can be run interactively. This is particularly useful
when developing or debugging a test: when developing or debugging a test:
```ShellSession ```ShellSession
$ nix-build nixos/tests/login.nix -A driverInteractive $ nix-build . -A nixosTests.login.driverInteractive
$ ./result/bin/nixos-test-driver --interactive $ ./result/bin/nixos-test-driver --interactive
starting VDE switch for network 1 [...]
> >>>
``` ```
You can then take any Python statement, e.g. You can then take any Python statement, e.g.
```py ```py
> start_all() >>> start_all()
> test_script() >>> test_script()
> machine.succeed("touch /tmp/foo") >>> machine.succeed("touch /tmp/foo")
> print(machine.succeed("pwd")) # Show stdout of command >>> print(machine.succeed("pwd")) # Show stdout of command
``` ```
The function `test_script` executes the entire test script and drops you The function `test_script` executes the entire test script and drops you

View File

@ -5,19 +5,19 @@
useful when developing or debugging a test: useful when developing or debugging a test:
</para> </para>
<programlisting> <programlisting>
$ nix-build nixos/tests/login.nix -A driverInteractive $ nix-build . -A nixosTests.login.driverInteractive
$ ./result/bin/nixos-test-driver --interactive $ ./result/bin/nixos-test-driver --interactive
starting VDE switch for network 1 [...]
&gt; &gt;&gt;&gt;
</programlisting> </programlisting>
<para> <para>
You can then take any Python statement, e.g. You can then take any Python statement, e.g.
</para> </para>
<programlisting language="python"> <programlisting language="python">
&gt; start_all() &gt;&gt;&gt; start_all()
&gt; test_script() &gt;&gt;&gt; test_script()
&gt; machine.succeed(&quot;touch /tmp/foo&quot;) &gt;&gt;&gt; machine.succeed(&quot;touch /tmp/foo&quot;)
&gt; print(machine.succeed(&quot;pwd&quot;)) # Show stdout of command &gt;&gt;&gt; print(machine.succeed(&quot;pwd&quot;)) # Show stdout of command
</programlisting> </programlisting>
<para> <para>
The function <literal>test_script</literal> executes the entire test The function <literal>test_script</literal> executes the entire test

View File

@ -17,7 +17,7 @@ rec {
inherit pkgs; inherit pkgs;
# Run an automated test suite in the given virtual network. # Run an automated test suite in the given virtual network.
runTests = { driver, pos }: runTests = { driver, driverInteractive, pos }:
stdenv.mkDerivation { stdenv.mkDerivation {
name = "vm-test-run-${driver.testName}"; name = "vm-test-run-${driver.testName}";
@ -34,7 +34,7 @@ rec {
''; '';
passthru = driver.passthru // { passthru = driver.passthru // {
inherit driver; inherit driver driverInteractive;
}; };
inherit pos; # for better debugging inherit pos; # for better debugging
@ -224,7 +224,7 @@ rec {
passMeta = drv: drv // lib.optionalAttrs (t ? meta) { passMeta = drv: drv // lib.optionalAttrs (t ? meta) {
meta = (drv.meta or { }) // t.meta; meta = (drv.meta or { }) // t.meta;
}; };
in passMeta (runTests { inherit driver pos; }); in passMeta (runTests { inherit driver pos driverInteractive; });
in in
test // { test // {