Skip to content

Commit

Permalink
Merge pull request #26736 from grahamc/improve-nixos-test-debug
Browse files Browse the repository at this point in the history
Improve nixos test debug
  • Loading branch information
grahamc committed Jun 21, 2017
2 parents bc47794 + 3f40fca commit dd26531
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions nixos/lib/test-driver/Machine.pm
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ sub waitForMonitorPrompt {
sub retry {
my ($coderef) = @_;
my $n;
for ($n = 0; $n < 900; $n++) {
return if &$coderef;
for ($n = 899; $n >=0; $n--) {
return if &$coderef($n);
sleep 1;
}
die "action timed out after $n seconds";
Expand Down Expand Up @@ -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/;
}
});
Expand Down Expand Up @@ -566,6 +572,12 @@ sub waitForText {
my ($self, $regexp) = @_;
$self->nest("waiting for $regexp to appear on the screen", sub {
retry sub {
my ($retries_remaining) = @_;
if ($retries_remaining == 0) {
$self->log("Last chance to match /$regexp/ on the screen, which currently contains:");
$self->log($self->getScreenText);
}

return 1 if $self->getScreenText =~ /$regexp/;
}
});
Expand Down Expand Up @@ -600,6 +612,13 @@ sub waitForWindow {
$self->nest("waiting for a window to appear", sub {
retry sub {
my @names = $self->getWindowNames;

my ($retries_remaining) = @_;
if ($retries_remaining == 0) {
$self->log("Last chance to match /$regexp/ on the the window list, which currently contains:");
$self->log(join(", ", @names));
}

foreach my $n (@names) {
return 1 if $n =~ /$regexp/;
}
Expand Down

0 comments on commit dd26531

Please sign in to comment.