Skip to content

Commit 25b2647

Browse files
committed
test(php): collect host stderr and allow slower startup
1 parent d1841dc commit 25b2647

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

php/tests/ClientTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ private function spawnHost(int $port, bool $autoPong = true, bool $sendControl =
3636
return [$proc, $pipes];
3737
}
3838

39-
private function readEvents($pipe, float $timeout = 2.0): array
39+
private function readEvents($pipe, float $timeout = 4.0, $errPipe = null): array
4040
{
4141
$events = [];
4242
$deadline = microtime(true) + $timeout;
4343
while (microtime(true) < $deadline) {
4444
$data = stream_get_contents($pipe);
45+
if ($errPipe) {
46+
$errData = stream_get_contents($errPipe);
47+
if ($errData !== false && $errData !== '') {
48+
$data .= "\n" . $errData;
49+
}
50+
}
4551
if ($data !== false && $data !== '') {
4652
foreach (explode("\n", $data) as $line) {
4753
if (trim($line) === '') {
@@ -110,7 +116,7 @@ public function testHandshakeBufferingAndDropNotice(): void
110116
$pid = $this->forkClient($client, 2);
111117
$this->waitForChild($pid, 5);
112118

113-
$events = $this->readEvents($pipes[1]);
119+
$events = $this->readEvents($pipes[1], 4.0, $pipes[2]);
114120
proc_terminate($proc);
115121

116122
$recv = array_values(array_filter(array_map(fn($e) => $e['msg'] ?? null, $events)));
@@ -150,7 +156,7 @@ public function testControlRoundTrip(): void
150156
$pid = $this->forkClient($client, 2);
151157
$this->waitForChild($pid, 5);
152158

153-
$events = $this->readEvents($pipes[1], 3.0);
159+
$events = $this->readEvents($pipes[1], 4.0, $pipes[2]);
154160
proc_terminate($proc);
155161

156162
$controlResult = null;
@@ -176,7 +182,7 @@ public function testHeartbeatReconnect(): void
176182
$pid = $this->forkClient($client, 3);
177183
$this->waitForChild($pid, 6);
178184

179-
$events = $this->readEvents($pipes[1], 3.0);
185+
$events = $this->readEvents($pipes[1], 4.0, $pipes[2]);
180186
proc_terminate($proc);
181187

182188
$recv = array_values(array_filter(array_map(fn($e) => $e['msg'] ?? null, $events)));

0 commit comments

Comments
 (0)