| 184 | |
| 185 | template <typename T> |
| 186 | ::testing::AssertionResult AwaitAssertAbandoned( |
| 187 | const char* expr, |
| 188 | const char*, // Unused string representation of 'duration'. |
| 189 | const process::Future<T>& actual, |
| 190 | const Duration& duration) |
| 191 | { |
| 192 | process::Owned<process::Latch> latch(new process::Latch()); |
| 193 | |
| 194 | actual.onAny([=]() { latch->trigger(); }); |
| 195 | actual.onAbandoned([=]() { latch->trigger(); }); |
| 196 | |
| 197 | if (!latch->await(duration)) { |
| 198 | return ::testing::AssertionFailure() |
| 199 | << "Failed to wait " << duration << " for " << expr; |
| 200 | } else if (actual.isDiscarded()) { |
| 201 | return ::testing::AssertionFailure() |
| 202 | << expr << " was discarded"; |
| 203 | } else if (actual.isReady()) { |
| 204 | return ::testing::AssertionFailure() |
| 205 | << expr << " is ready (" << ::testing::PrintToString(actual.get()) << ")"; |
| 206 | } else if (actual.isFailed()) { |
| 207 | return ::testing::AssertionFailure() |
| 208 | << "(" << expr << ").failure(): " << actual.failure(); |
| 209 | } |
| 210 | |
| 211 | CHECK_ABANDONED(actual); |
| 212 | |
| 213 | return ::testing::AssertionSuccess(); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | template <typename T1, typename T2> |