File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
src/Symfony/Component/Process Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -557,6 +557,7 @@ public function getIterator($flags = 0)
557557 yield self ::OUT => '' ;
558558 }
559559
560+ $ this ->checkTimeout ();
560561 $ this ->readPipesForOutput (__FUNCTION__ , $ blocking );
561562 }
562563 }
Original file line number Diff line number Diff line change @@ -747,6 +747,27 @@ public function testRunProcessWithTimeout()
747747 throw $ e ;
748748 }
749749
750+ /**
751+ * @expectedException \Symfony\Component\Process\Exception\ProcessTimedOutException
752+ * @expectedExceptionMessage exceeded the timeout of 0.1 seconds.
753+ */
754+ public function testIterateOverProcessWithTimeout ()
755+ {
756+ $ process = $ this ->getProcess (self ::$ phpBin .' -r "sleep(30);" ' );
757+ $ process ->setTimeout (0.1 );
758+ $ start = microtime (true );
759+ try {
760+ $ process ->start ();
761+ foreach ($ process as $ buffer );
762+ $ this ->fail ('A RuntimeException should have been raised ' );
763+ } catch (RuntimeException $ e ) {
764+ }
765+
766+ $ this ->assertLessThan (15 , microtime (true ) - $ start );
767+
768+ throw $ e ;
769+ }
770+
750771 public function testCheckTimeoutOnNonStartedProcess ()
751772 {
752773 $ process = $ this ->getProcess ('echo foo ' );
You can’t perform that action at this time.
0 commit comments