@@ -13,9 +13,10 @@ final class TestsRunner
1313 private const PARALLEL_PARAM = '--parallel=2 ' ;
1414 private const CACHE_PARAM = '--cache=temp/cache.json ' ;
1515
16- private const EXIT_CODE_OK = 0 ;
17- private const EXIT_CODE_ERROR = 1 ;
18- private const EXIT_CODE_FIXABLE_ERROR = 2 ;
16+ private const EXIT_CODE_OK = 0 ; // or all fixable errors were fixed and there is no error
17+ private const EXIT_CODE_AUTO_FIXABLE_ERROR = 1 ;
18+ private const EXIT_CODE_NON_AUTO_FIXABLE_ERROR = 2 ;
19+ private const EXIT_CODE_AUTO_AND_NON_AUTO_FIXABLE_ERROR = 3 ;
1920
2021 /**
2122 * [$title, $parameters, $cleanCache]
@@ -149,7 +150,7 @@ private function tests2(): bool
149150 echo sprintf (' - %s: ' , $ title );
150151
151152 $ exec = $ this ->exec (self ::PHPCS_BIN , 'tests02 ' , null , $ params );
152- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_ERROR ) {
153+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_NON_AUTO_FIXABLE_ERROR ) {
153154 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
154155 return false ;
155156 }
@@ -220,7 +221,7 @@ private function tests4(): bool
220221 echo sprintf (' - %s: ' , $ title );
221222
222223 $ exec = $ this ->exec (self ::PHPCS_BIN , 'tests04 ' , self ::BOOTSTRAP_PARAM , $ params );
223- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_FIXABLE_ERROR ) {
224+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_AUTO_FIXABLE_ERROR ) {
224225 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
225226 return false ;
226227 }
@@ -261,7 +262,7 @@ private function tests5(): bool
261262 echo sprintf (' - %s: ' , $ title );
262263
263264 $ exec = $ this ->exec (self ::PHPCS_BIN , 'tests05 ' , self ::BOOTSTRAP_PARAM , $ params );
264- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_ERROR ) {
265+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_NON_AUTO_FIXABLE_ERROR ) {
265266 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
266267 return false ;
267268 }
@@ -332,7 +333,7 @@ private function tests7(): bool
332333 echo sprintf (' - %s: ' , $ title );
333334
334335 $ exec = $ this ->exec (self ::PHPCS_BIN , 'tests07 ' , self ::BOOTSTRAP_PARAM , $ params );
335- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_FIXABLE_ERROR ) {
336+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_AUTO_AND_NON_AUTO_FIXABLE_ERROR ) {
336337 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
337338 return false ;
338339 }
@@ -414,7 +415,7 @@ private function tests9(): bool
414415 echo sprintf (' - %s: ' , $ title );
415416
416417 $ exec = $ this ->exec (self ::PHPCS_BIN , 'tests09 ' , self ::BOOTSTRAP_OUTDATED_PARAM , $ params );
417- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_ERROR ) {
418+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_NON_AUTO_FIXABLE_ERROR ) {
418419 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
419420 return false ;
420421 }
@@ -453,6 +454,8 @@ private function tests10(): bool
453454 foreach (self ::DEFAULT_TEST_CASES as $ test ) {
454455 [$ title , $ params , $ cleanCache ] = $ test ;
455456
457+ $ params [] = '2>&1 ' ; // we want an error output
458+
456459 echo sprintf (' - %s: ' , $ title );
457460
458461 $ exec = $ this ->exec (self ::PHPCBF_BIN , 'tests10 ' , self ::BOOTSTRAP_PARAM , $ params );
@@ -485,7 +488,7 @@ private function tests11(): bool
485488 echo sprintf (' - %s: ' , $ title );
486489
487490 $ exec = $ this ->exec (self ::PHPCBF_BIN , 'tests11 ' , self ::BOOTSTRAP_PARAM , $ params );
488- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_ERROR ) {
491+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_OK ) {
489492 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
490493 return false ;
491494 }
@@ -527,7 +530,7 @@ private function tests12(): bool
527530 echo sprintf (' - %s: ' , $ title );
528531
529532 $ exec = $ this ->exec (self ::PHPCS_BIN , 'tests12 ' , self ::BOOTSTRAP_PARAM , $ params , '\\\\Forrest79 \\\\PhpCsIgnores \\\\BaselineReport ' );
530- if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_FIXABLE_ERROR ) {
533+ if ($ exec ['exitCode ' ] !== self ::EXIT_CODE_AUTO_FIXABLE_ERROR ) {
531534 echo 'PHPCS exited unexpectedly ' . PHP_EOL ;
532535 return false ;
533536 }
@@ -581,7 +584,7 @@ private function exec(
581584 $ parameters [] = $ boostrap ;
582585 }
583586
584- $ command = sprintf ('%s --standard=%s/phpcs.xml --report=%s %s -s %s ' , $ bin , $ dir , $ report , implode (' ' , $ parameters ), $ dir );
587+ $ command = sprintf ('%s --standard=%s/phpcs.xml --report=%s %s -q - s %s ' , $ bin , $ dir , $ report , implode (' ' , $ parameters ), $ dir );
585588
586589 if (exec ($ command , $ output , $ exitCode ) === false ) {
587590 throw new \RuntimeException ('Can \'t run PHPCS. ' );
0 commit comments