Skip to content

Commit

Permalink
Improve test suite to skip tests that exhibit a race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Aug 1, 2021
1 parent fb0548a commit 636e151
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@ public function testWriteClientLogin(Client $client, \stdClass $message)
$message = $this->awaitMessage($client);
$this->assertEquals('ClientLoginAck', $message->MsgType);

try {
$message = $this->awaitMessage($client);
} catch (\React\Promise\Timer\TimeoutException $e) {
$this->markTestIncomplete('Unhandled race condition, please retry');
}
$message = $this->awaitMessage($client);
$this->assertEquals('SessionInit', $message->MsgType);

return $message;
Expand Down Expand Up @@ -290,11 +286,15 @@ public function testCreateClientWithInvalidAuthUrlRejects()

private function awaitMessage(Client $client)
{
return Block\await(new Promise(function ($resolve, $reject) use ($client) {
$client->once('data', $resolve);
try {
return Block\await(new Promise(function ($resolve, $reject) use ($client) {
$client->once('data', $resolve);

$client->once('error', $reject);
$client->once('close', $reject);
}), Loop::get(), 10.0);
$client->once('error', $reject);
$client->once('close', $reject);
}), Loop::get(), 10.0);
} catch (\React\Promise\Timer\TimeoutException $e) {
$this->markTestIncomplete('Unhandled race condition, please retry');
}
}
}

0 comments on commit 636e151

Please sign in to comment.