Fix and make tests more reliable.

This commit is contained in:
Daniel Nichter
2011-07-14 11:05:05 -06:00
parent db76b3ca30
commit 7526f97224
8 changed files with 40 additions and 32 deletions

View File

@@ -255,12 +255,17 @@ sub wait_for {
}
sub wait_for_table {
my ($dbh, $tbl) = @_;
my ($dbh, $tbl, $where) = @_;
my $sql = "SELECT 1 FROM $tbl" . ($where ? " WHERE $where LIMIT 1" : "");
return wait_until(
sub {
my $r;
eval { $r = $dbh->selectrow_arrayref("SELECT 1 FROM $tbl"); };
return $EVAL_ERROR ? 0 : 1;
eval { $r = $dbh->selectrow_arrayref($sql); };
return 0 if $EVAL_ERROR;
if ( $where ) {
return 0 unless $r && @$r;
}
return 1;
},
0.25,
15,