summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2017-06-20 20:55:52 -0400
committerGraham Christensen <graham@grahamc.com>2017-06-20 20:57:39 -0400
commit348785eec0c499dc4f79943cedcd78be279ca41d (patch)
treeaaddba1c5c5b25de5594109d3bacc5b708247491 /nixos
parent56435c140413ae43530d03ae1db3c8cdd43d3838 (diff)
downloadnixlib-348785eec0c499dc4f79943cedcd78be279ca41d.tar
nixlib-348785eec0c499dc4f79943cedcd78be279ca41d.tar.gz
nixlib-348785eec0c499dc4f79943cedcd78be279ca41d.tar.bz2
nixlib-348785eec0c499dc4f79943cedcd78be279ca41d.tar.lz
nixlib-348785eec0c499dc4f79943cedcd78be279ca41d.tar.xz
nixlib-348785eec0c499dc4f79943cedcd78be279ca41d.tar.zst
nixlib-348785eec0c499dc4f79943cedcd78be279ca41d.zip
nixos tests: waitUntilTTYMatches: Log TTY contents on last try
If the test has not passed yet, on the last attempt it now outputs:

    machine: Last chance to match /logine: / on TTY2, which currently contains:
    machine: running command: fold -w$(stty -F /dev/tty2 size | awk '{print $2}') /dev/vcs2
    machine: exit status 0
    machine:

    <<< Welcome to NixOS 17.09.git.a804ef4 (x86_64) - tty2 >>>

    machine login:

to help debug the problem. Notice the "logine" typo in my check.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/lib/test-driver/Machine.pm6
1 files changed, 6 insertions, 0 deletions
diff --git a/nixos/lib/test-driver/Machine.pm b/nixos/lib/test-driver/Machine.pm
index c88f9f2bbbe3..973e05542d58 100644
--- a/nixos/lib/test-driver/Machine.pm
+++ b/nixos/lib/test-driver/Machine.pm
@@ -518,6 +518,12 @@ sub waitUntilTTYMatches {
 
     $self->nest("waiting for $regexp to appear on tty $tty", sub {
         retry sub {
+            my ($retries_remaining) = @_;
+            if ($retries_remaining == 0) {
+                $self->log("Last chance to match /$regexp/ on TTY$tty, which currently contains:");
+                $self->log($self->getTTYText($tty));
+            }
+
             return 1 if $self->getTTYText($tty) =~ /$regexp/;
         }
     });