|
55 | 55 | await_condition/2,
|
56 | 56 | await_condition_with_retries/2,
|
57 | 57 |
|
| 58 | + await_condition_ignoring_exceptions/1, |
| 59 | + await_condition_ignoring_exceptions/2, |
| 60 | + await_condition_with_retries_ignoring_exceptions/2, |
| 61 | + |
58 | 62 | eventually/1, eventually/3,
|
59 | 63 | consistently/1, consistently/3,
|
60 | 64 |
|
@@ -1138,6 +1142,28 @@ await_condition_with_retries(ConditionFun, RetriesLeft) ->
|
1138 | 1142 | ok
|
1139 | 1143 | end.
|
1140 | 1144 |
|
| 1145 | +await_condition_ignoring_exceptions(ConditionFun) -> |
| 1146 | + await_condition_ignoring_exceptions(ConditionFun, 10_000). |
| 1147 | + |
| 1148 | +await_condition_ignoring_exceptions(ConditionFun, Timeout) -> |
| 1149 | + Retries = ceil(Timeout / 50), |
| 1150 | + await_condition_with_retries_ignoring_exceptions(ConditionFun, Retries). |
| 1151 | + |
| 1152 | +await_condition_with_retries_ignoring_exceptions(_ConditionFun, 0) -> |
| 1153 | + ct:fail("Condition did not materialize in the expected period of time"); |
| 1154 | +await_condition_with_retries_ignoring_exceptions(ConditionFun, RetriesLeft) -> |
| 1155 | + try ConditionFun() of |
| 1156 | + false -> |
| 1157 | + timer:sleep(50), |
| 1158 | + await_condition_with_retries_ignoring_exceptions(ConditionFun, RetriesLeft - 1); |
| 1159 | + true -> |
| 1160 | + ok |
| 1161 | + catch |
| 1162 | + _:_ -> |
| 1163 | + timer:sleep(50), |
| 1164 | + await_condition_with_retries_ignoring_exceptions(ConditionFun, RetriesLeft - 1) |
| 1165 | + end. |
| 1166 | + |
1141 | 1167 | %% Pass in any EUnit test object. Example:
|
1142 | 1168 | %% eventually(?_assertEqual(1, Actual))
|
1143 | 1169 | eventually({Line, Assertion} = TestObj)
|
|
0 commit comments