Skip to content

Commit d20fc5a

Browse files
committed
Make proc_open_bug64438.phpt more robust
The test currently assumes that we'll first read the data of stdout and stderr and then see eof on stdout and stderr. However we could also read stdout, see eof on stdout, read stderr and see eof on stderr, depending on timing. Avoid output ordering issues by collecting events into a per-pipe array, so interleaving is not visible.
1 parent 3b73c9f commit d20fc5a

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

ext/standard/tests/streams/proc_open_bug64438.phpt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $stdinOffset = 0;
2525

2626
unset($pipes[0]);
2727

28+
$pipeEvents = [];
2829
while ($pipes || $writePipes) {
2930
$r = $pipes;
3031
$w = $writePipes;
@@ -51,19 +52,35 @@ while ($pipes || $writePipes) {
5152
foreach ($r as $pipe) {
5253
$type = array_search($pipe, $pipes);
5354
$data = fread($pipe, 8192);
54-
var_dump($data);
5555
if (false === $data || feof($pipe)) {
56+
$pipeEvents[(int)$pipe][] = "Closing pipe";
5657
fclose($pipe);
5758
unset($pipes[$type]);
59+
} else {
60+
$pipeEvents[(int)$pipe][] = "Read " . strlen($data) . " bytes";
5861
}
5962
}
6063
}
6164

65+
var_dump($pipeEvents);
66+
6267
?>
6368
===DONE===
6469
--EXPECTF--
65-
string(4097) "%s"
66-
string(4097) "%s"
67-
string(0) ""
68-
string(0) ""
70+
array(2) {
71+
[%d]=>
72+
array(2) {
73+
[0]=>
74+
string(15) "Read 4097 bytes"
75+
[1]=>
76+
string(12) "Closing pipe"
77+
}
78+
[%d]=>
79+
array(2) {
80+
[0]=>
81+
string(15) "Read 4097 bytes"
82+
[1]=>
83+
string(12) "Closing pipe"
84+
}
85+
}
6986
===DONE===

0 commit comments

Comments
 (0)