@@ -276,6 +276,37 @@ public function testGetIncrementalErrorOutput()
276
276
unlink ($ lock );
277
277
}
278
278
279
+ public function testGetEmptyIncrementalErrorOutput ()
280
+ {
281
+ // use a lock file to toggle between writing ("W") and reading ("R") the
282
+ // output stream
283
+ $ lock = tempnam (sys_get_temp_dir (), get_class ($ this ).'Lock ' );
284
+ file_put_contents ($ lock , 'W ' );
285
+
286
+ $ p = $ this ->getProcess (sprintf ('php -r %s ' , escapeshellarg ('$n = 0; while ($n < 3) { if ( \'W \' === file_get_contents( ' .var_export ($ lock , true ).')) { file_put_contents( \'php://stderr \', \'ERROR \'); $n++; file_put_contents( ' .var_export ($ lock , true ).', \'R \'); } usleep(100); } ' )));
287
+
288
+ $ p ->start ();
289
+
290
+ $ shouldWrite = false ;
291
+
292
+ while ($ p ->isRunning ()) {
293
+ if ('R ' === file_get_contents ($ lock )) {
294
+ if (!$ shouldWrite ) {
295
+ $ this ->assertLessThanOrEqual (1 , preg_match_all ('/ERROR/ ' , $ p ->getIncrementalOutput (), $ matches ));
296
+ $ shouldWrite = true ;
297
+ } else {
298
+ $ this ->assertSame ('' , $ p ->getIncrementalOutput ());
299
+
300
+ file_put_contents ($ lock , 'W ' );
301
+ $ shouldWrite = false ;
302
+ }
303
+ }
304
+ usleep (100 );
305
+ }
306
+
307
+ unlink ($ lock );
308
+ }
309
+
279
310
public function testGetOutput ()
280
311
{
281
312
$ p = $ this ->getProcess (sprintf ('php -r %s ' , escapeshellarg ('$n = 0; while ($n < 3) { echo \' foo \'; $n++; } ' )));
@@ -305,6 +336,37 @@ public function testGetIncrementalOutput()
305
336
unlink ($ lock );
306
337
}
307
338
339
+ public function testGetEmptyIncrementalOutput ()
340
+ {
341
+ // use a lock file to toggle between writing ("W") and reading ("R") the
342
+ // output stream
343
+ $ lock = tempnam (sys_get_temp_dir (), get_class ($ this ).'Lock ' );
344
+ file_put_contents ($ lock , 'W ' );
345
+
346
+ $ p = $ this ->getProcess (sprintf ('php -r %s ' , escapeshellarg ('$n = 0; while ($n < 3) { if ( \'W \' === file_get_contents( ' .var_export ($ lock , true ).')) { echo \' foo \'; $n++; file_put_contents( ' .var_export ($ lock , true ).', \'R \'); } usleep(100); } ' )));
347
+
348
+ $ p ->start ();
349
+
350
+ $ shouldWrite = false ;
351
+
352
+ while ($ p ->isRunning ()) {
353
+ if ('R ' === file_get_contents ($ lock )) {
354
+ if (!$ shouldWrite ) {
355
+ $ this ->assertLessThanOrEqual (1 , preg_match_all ('/foo/ ' , $ p ->getIncrementalOutput (), $ matches ));
356
+ $ shouldWrite = true ;
357
+ } else {
358
+ $ this ->assertSame ('' , $ p ->getIncrementalOutput ());
359
+
360
+ file_put_contents ($ lock , 'W ' );
361
+ $ shouldWrite = false ;
362
+ }
363
+ }
364
+ usleep (100 );
365
+ }
366
+
367
+ unlink ($ lock );
368
+ }
369
+
308
370
public function testZeroAsOutput ()
309
371
{
310
372
if ('\\' === DIRECTORY_SEPARATOR ) {
0 commit comments