@@ -54,17 +54,37 @@ public function __construct(Application $application)
5454 */
5555 public function run (array $ input , $ options = [])
5656 {
57- $ this ->input = new ArrayInput ($ input );
58- if (isset ($ options ['interactive ' ])) {
59- $ this ->input ->setInteractive ($ options ['interactive ' ]);
60- }
57+ $ prevShellVerbosity = getenv ('SHELL_VERBOSITY ' );
6158
62- if ($ this ->inputs ) {
63- $ this ->input ->setStream (self ::createStream ($ this ->inputs ));
64- }
59+ try {
60+ $ this ->input = new ArrayInput ($ input );
61+ if (isset ($ options ['interactive ' ])) {
62+ $ this ->input ->setInteractive ($ options ['interactive ' ]);
63+ }
6564
66- $ this ->initOutput ($ options );
65+ if ($ this ->inputs ) {
66+ $ this ->input ->setStream (self ::createStream ($ this ->inputs ));
67+ }
6768
68- return $ this ->statusCode = $ this ->application ->run ($ this ->input , $ this ->output );
69+ $ this ->initOutput ($ options );
70+
71+ return $ this ->statusCode = $ this ->application ->run ($ this ->input , $ this ->output );
72+ } finally {
73+ // SHELL_VERBOSITY is set by Application::configureIO so we need to unset/reset it
74+ // to its previous value to avoid one test's verbosity to spread to the following tests
75+ if (false === $ prevShellVerbosity ) {
76+ if (\function_exists ('putenv ' )) {
77+ @putenv ('SHELL_VERBOSITY ' );
78+ }
79+ unset($ _ENV ['SHELL_VERBOSITY ' ]);
80+ unset($ _SERVER ['SHELL_VERBOSITY ' ]);
81+ } else {
82+ if (\function_exists ('putenv ' )) {
83+ @putenv ('SHELL_VERBOSITY= ' .$ prevShellVerbosity );
84+ }
85+ $ _ENV ['SHELL_VERBOSITY ' ] = $ prevShellVerbosity ;
86+ $ _SERVER ['SHELL_VERBOSITY ' ] = $ prevShellVerbosity ;
87+ }
88+ }
6989 }
7090}
0 commit comments