Browse Source

Handling custom exit codes

Jeremy Harris 7 years ago
parent
commit
cc17cdeca8

+ 1 - 1
src/TestSuite/ConsoleIntegrationTestCase.php

@@ -95,7 +95,7 @@ abstract class ConsoleIntegrationTestCase extends TestCase
         try {
             $this->_exitCode = $runner->run($args, $io);
         } catch (StopException $exception) {
-            $this->_exitCode = Command::CODE_ERROR;
+            $this->_exitCode = $exception->getCode();
         }
     }
 

+ 1 - 1
tests/TestCase/TestSuite/ConsoleIntegrationTestCaseTest.php

@@ -80,7 +80,7 @@ class ConsoleIntegrationTestCaseTest extends ConsoleIntegrationTestCase
     {
         $this->useCommandRunner();
         $this->exec('abort_command');
-        $this->assertExitCode(Shell::CODE_ERROR);
+        $this->assertExitCode(127);
         $this->assertErrorContains('Command aborted');
     }
 

+ 1 - 1
tests/test_app/TestApp/Command/AbortCommand.php

@@ -10,6 +10,6 @@ class AbortCommand extends Command
     public function execute(Arguments $args, ConsoleIo $io)
     {
         $io->error('Command aborted');
-        $this->abort();
+        $this->abort(127);
     }
 }