diff options
author | aszlig <aszlig@redmoonstudios.org> | 2015-05-21 19:49:08 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2015-05-21 19:55:21 +0200 |
commit | 8bd025a75e295609647af0510544efb857678ec8 (patch) | |
tree | 1229c4f7f47d6f3c5e3c547b3c03bad0b99e975a /nixos/lib/test-driver | |
parent | 235c2228ca9f608f898bc455c9b5bb1e3c4cb3f0 (diff) | |
download | nixpkgs-8bd025a75e295609647af0510544efb857678ec8.tar nixpkgs-8bd025a75e295609647af0510544efb857678ec8.tar.gz nixpkgs-8bd025a75e295609647af0510544efb857678ec8.tar.bz2 nixpkgs-8bd025a75e295609647af0510544efb857678ec8.tar.lz nixpkgs-8bd025a75e295609647af0510544efb857678ec8.tar.xz nixpkgs-8bd025a75e295609647af0510544efb857678ec8.tar.zst nixpkgs-8bd025a75e295609647af0510544efb857678ec8.zip |
nixos/test-driver: Add new waitForText function.
As promised in the previous commit, this can be used similarly to $machine->waitForWindow, where you supply a regular expression and it's retrying OCR until the regexp matches. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'nixos/lib/test-driver')
-rw-r--r-- | nixos/lib/test-driver/Machine.pm | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm index 0dddc1dc14b..d149634e9e6 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 { |