nixos tests: retry: Count down to 0, and pass remaining attempts to the sub

Allows test functions to output diagnostic information on failure.
This commit is contained in:
Graham Christensen 2017-06-20 19:53:25 -04:00
parent d04286be34
commit 56435c1404
No known key found for this signature in database
GPG Key ID: 06121D366FE9435C

View File

@ -219,8 +219,8 @@ sub waitForMonitorPrompt {
sub retry { sub retry {
my ($coderef) = @_; my ($coderef) = @_;
my $n; my $n;
for ($n = 0; $n < 900; $n++) { for ($n = 899; $n >=0; $n--) {
return if &$coderef; return if &$coderef($n);
sleep 1; sleep 1;
} }
die "action timed out after $n seconds"; die "action timed out after $n seconds";