lntest/wait: handle the case where the pred func hangs
This commit fixes a bug in the wait.NoError function. If the predicate function, f, passed to the NoError function would hang for the full timeout, then the `predErr` would remain nil and so a nil error would be returned from the function. This commit handles that case.
This commit is contained in:
1 file changed
+7
@@ -58,6 +58,13 @@ func NoError(f func() error, timeout time.Duration) error {
|
||||
// If f() doesn't succeed within the timeout, return the last
|
||||
// encountered error.
|
||||
if err := Predicate(pred, timeout); err != nil {
|
||||
// Handle the case where the passed in method, f, hangs for the
|
||||
// full timeout
|
||||
if predErr == nil {
|
||||
return fmt.Errorf("method did not return within the " +
|
||||
"timeout")
|
||||
}
|
||||
|
||||
return predErr
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user