Skip to content

Commit d5333a5

Browse files
SlamdunkNaktibalda
authored andcommitted
Shortened error output of unexpected exit to one line.
* Test early exits * Exit with error code * Test exit code
1 parent c3d6060 commit d5333a5

File tree

10 files changed

+78
-2
lines changed

10 files changed

+78
-2
lines changed

src/Codeception/Subscriber/ErrorHandler.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ public function shutdownHandler()
9898
if (!$this->suiteFinished && (
9999
$error === null || !in_array($error['type'], [E_ERROR, E_COMPILE_ERROR, E_CORE_ERROR])
100100
)) {
101-
throw new \RuntimeException('Command Did Not Finish Properly');
102-
} elseif (!is_array($error)) {
101+
echo "\n\n\nCOMMAND DID NOT FINISH PROPERLY.\n";
102+
exit(255);
103+
}
104+
if (!is_array($error)) {
103105
return;
104106
}
105107
if (error_reporting() === 0) {

tests/cli/ErrorHandlerCest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
class ErrorHandlerCest
3+
{
4+
/**
5+
* @param CliGuy $I
6+
*/
7+
public function earlyExitWarnsTheUser(\CliGuy $I)
8+
{
9+
$I->executeFailCommand('run -c tests/data/first_test_exits');
10+
11+
$I->seeResultCodeIs(255);
12+
$I->seeInShellOutput('COMMAND DID NOT FINISH PROPERLY');
13+
}
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
actor: Tester
2+
paths:
3+
tests: tests
4+
log: tests/_output
5+
data: tests/_data
6+
support: tests/_support
7+
envs: tests/_envs
8+
settings:
9+
bootstrap: _bootstrap.php
10+
colors: true
11+
memory_limit: 1024M
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
// This is global bootstrap for autoloading
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
4+
/**
5+
* Inherited Methods
6+
* @method void wantToTest($text)
7+
* @method void wantTo($text)
8+
* @method void execute($callable)
9+
* @method void expectTo($prediction)
10+
* @method void expect($prediction)
11+
* @method void amGoingTo($argumentation)
12+
* @method void am($role)
13+
* @method void lookForwardTo($achieveValue)
14+
* @method void comment($description)
15+
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
16+
*
17+
* @SuppressWarnings(PHPMD)
18+
*/
19+
class UnitTester extends \Codeception\Actor
20+
{
21+
use _generated\UnitTesterActions;
22+
23+
/**
24+
* Define custom actions here
25+
*/
26+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Codeception Test Suite Configuration
2+
#
3+
# Suite for unit (internal) tests.
4+
5+
class_name: UnitTester
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
4+
class ExitCest
5+
{
6+
public function exitNow(UnitTester $I)
7+
{
8+
exit(0);
9+
}
10+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
// Here you can initialize variables that will be available to your tests

0 commit comments

Comments
 (0)