From 636e1517e36786a0d538bc83ae22343e001ddac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sun, 1 Aug 2021 16:42:44 +0200 Subject: [PATCH] Improve test suite to skip tests that exhibit a race condition --- tests/FunctionalTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index 0cab36b..121ae23 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -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; @@ -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'); + } } }