git.iko.soy/typeable/nixpkgs
on master help sign in
nixosTest: Add xclip as example of stdout blocker
commit2a4d433b1f194595c819cec88361a1e402ebadb8 authorRobert Hensing <robert@roberthensing.nl> dateSat 6 Nov 2021, 13:05 (5 years ago) parentac971cd
4 files changed+18−9
nixos/doc/manual/development/writing-nixos-tests.section.md+5−2 nixos/doc/manual/from_md/development/writing-nixos-tests.section.xml+8−3 nixos/doc/manual/from_md/release-notes/rl-2111.section.xml+4−3 nixos/doc/manual/release-notes/rl-2111.section.md+1−1
nixos/doc/manual/development/writing-nixos-tests.section.md+5−2
@@ -162,7 +162,9 @@ The following methods are available on machine objects:
162162 If the command detaches, it must close stdout, as `execute` will wait
163163 for this to consume all output reliably. This can be achieved by
164164 redirecting stdout to stderr `>&2`, to `/dev/console`, `/dev/null` or
165− a file.
165+ a file. Examples of detaching commands are `sleep 365d &`, where the
166+ shell forks a new process that can write to stdout and `xclip -i`, where
167+ the `xclip` command itself forks without closing stdout.
166168 Takes an optional parameter `check_return` that defaults to `True`.
167169 Setting this parameter to `False` will not check for the return code
168170 and return -1 instead. This can be used for commands that shut down
@@ -183,7 +185,8 @@ The following methods are available on machine objects:
183185
184186 - Dereferencing unset variables fail the command.
185187
186− - It will wait for stdout to be closed. See `execute`.
188+ - It will wait for stdout to be closed. See `execute` for the
189+ implications.
187190
188191`fail`
189192
nixos/doc/manual/from_md/development/writing-nixos-tests.section.xml+8−3
@@ -271,8 +271,13 @@ start_all()
271271 for this to consume all output reliably. This can be achieved
272272 by redirecting stdout to stderr <literal>&gt;&amp;2</literal>,
273273 to <literal>/dev/console</literal>,
274− <literal>/dev/null</literal> or a file. Takes an optional
275− parameter <literal>check_return</literal> that defaults to
274+ <literal>/dev/null</literal> or a file. Examples of detaching
275+ commands are <literal>sleep 365d &amp;</literal>, where the
276+ shell forks a new process that can write to stdout and
277+ <literal>xclip -i</literal>, where the
278+ <literal>xclip</literal> command itself forks without closing
279+ stdout. Takes an optional parameter
280+ <literal>check_return</literal> that defaults to
276281 <literal>True</literal>. Setting this parameter to
277282 <literal>False</literal> will not check for the return code
278283 and return -1 instead. This can be used for commands that shut
@@ -314,7 +319,7 @@ start_all()
314319 <listitem>
315320 <para>
316321 It will wait for stdout to be closed. See
317− <literal>execute</literal>.
322+ <literal>execute</literal> for the implications.
318323 </para>
319324 </listitem>
320325 </itemizedlist>
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml+4−3
@@ -450,9 +450,10 @@
450450 <para>
451451 The NixOS VM test framework,
452452 <literal>pkgs.nixosTest</literal>/<literal>make-test-python.nix</literal>,
453− now requires non-terminating commands such as
454− <literal>succeed(&quot;foo &amp;&quot;)</literal> to close
455− stdout. This can be done with a redirect such as
453+ now requires detaching commands such as
454+ <literal>succeed(&quot;foo &amp;&quot;)</literal> and
455+ <literal>succeed(&quot;foo | xclip -i&quot;)</literal> to
456+ close stdout. This can be done with a redirect such as
456457 <literal>succeed(&quot;foo &gt;&amp;2 &amp;&quot;)</literal>.
457458 This breaking change was necessitated by a race condition
458459 causing tests to fail or hang. It applies to all methods that
nixos/doc/manual/release-notes/rl-2111.section.md+1−1
@@ -133,7 +133,7 @@ In addition to numerous new and upgraded packages, this release has the followin
133133
134134## Backward Incompatibilities {#sec-release-21.11-incompatibilities}
135135
136−- The NixOS VM test framework, `pkgs.nixosTest`/`make-test-python.nix`, now requires non-terminating commands such as `succeed("foo &")` to close stdout.
136+- The NixOS VM test framework, `pkgs.nixosTest`/`make-test-python.nix`, now requires detaching commands such as `succeed("foo &")` and `succeed("foo | xclip -i")` to close stdout.
137137 This can be done with a redirect such as `succeed("foo >&2 &")`. This breaking change was necessitated by a race condition causing tests to fail or hang.
138138 It applies to all methods that invoke commands on the nodes, including `execute`, `succeed`, `fail`, `wait_until_succeeds`, `wait_until_fails`.
139139