diff options
-rw-r--r-- | nixos/doc/manual/development/writing-nixos-tests.xml | 7 | ||||
-rw-r--r-- | nixos/lib/test-driver/Machine.pm | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/nixos/doc/manual/development/writing-nixos-tests.xml b/nixos/doc/manual/development/writing-nixos-tests.xml index 6224be0ca1a5..322778d1c209 100644 --- a/nixos/doc/manual/development/writing-nixos-tests.xml +++ b/nixos/doc/manual/development/writing-nixos-tests.xml @@ -245,6 +245,13 @@ startAll; </varlistentry> <varlistentry> + <term><methodname>waitForText</methodname></term> + <listitem><para>Wait until the supplied regular expressions matches + the textual contents of the screen by using optical character recognition + (see <methodname>getScreenText</methodname>).</para></listitem> + </varlistentry> + + <varlistentry> <term><methodname>waitForWindow</methodname></term> <listitem><para>Wait until an X11 window has appeared whose name matches the given regular expression, e.g., diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm index 0dddc1dc14b1..d149634e9e62 100644 --- a/nixos/lib/test-driver/Machine.pm +++ b/nixos/lib/test-driver/Machine.pm @@ -518,6 +518,17 @@ sub getScreenText { } +# Wait until a specific regexp matches the textual contents of the screen. +sub waitForText { + my ($self, $regexp) = @_; + $self->nest("waiting for $regexp to appear on the screen", sub { + retry sub { + return 1 if $self->getScreenText =~ /$regexp/; + } + }); +} + + # Wait until it is possible to connect to the X server. Note that # testing the existence of /tmp/.X11-unix/X0 is insufficient. sub waitForX { |