Skip to content

Commit f0e7094

Browse files
committed
fixup! fix(test): exit code of lime test
1 parent 680c9a2 commit f0e7094

File tree

2 files changed

+39
-21
lines changed

2 files changed

+39
-21
lines changed

lib/vendor/lime/lime.php

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,11 +1024,24 @@ function lime_shutdown()
10241024
ob_end_clean();
10251025
unlink($test_file);
10261026

1027+
$stats['status_code'] = $return;
10271028
$output = file_get_contents($result_file);
10281029
$stats['output'] = $output ? unserialize($output) : '';
1029-
if (!$stats['output'])
1030-
{
1031-
$stats['output'] = array(array('file' => $file, 'tests' => array(), 'stats' => array('plan' => 1, 'total' => 1, 'failed' => array(0), 'passed' => array(), 'skipped' => array(), 'errors' => array())));
1030+
if (!$stats['output']) {
1031+
$stats['output'] = array(
1032+
array(
1033+
'file' => $file,
1034+
'tests' => array(),
1035+
'stats' => array(
1036+
'plan' => 1,
1037+
'total' => 1,
1038+
'failed' => array(0),
1039+
'passed' => array(),
1040+
'skipped' => array(),
1041+
'errors' => array(),
1042+
),
1043+
),
1044+
);
10321045
}
10331046
unlink($result_file);
10341047

@@ -1037,23 +1050,10 @@ function lime_shutdown()
10371050

10381051
$delta = $this->computePlanDeltaFromFileStats($file_stats);
10391052

1040-
if ($return > 0)
1041-
{
1053+
if (0 === $stats['status_code']) {
1054+
$stats['status'] = 'ok';
1055+
} else {
10421056
$stats['status'] = $file_stats['failed'] ? 'not ok' : ($file_stats['errors'] ? 'errors' : 'dubious');
1043-
$stats['status_code'] = $return;
1044-
}
1045-
else
1046-
{
1047-
if (0 != $delta)
1048-
{
1049-
$stats['status'] = $file_stats['errors'] ? 'errors' : 'dubious';
1050-
$stats['status_code'] = 255;
1051-
}
1052-
else
1053-
{
1054-
$stats['status'] = $file_stats['errors'] ? 'errors' : 'ok';
1055-
$stats['status_code'] = 0;
1056-
}
10571057
}
10581058

10591059
if (true === $this->full_output)
@@ -1125,7 +1125,15 @@ function lime_shutdown()
11251125

11261126
if (isset($stat['output'][0]))
11271127
{
1128-
$this->output->echoln(sprintf($format, substr($relative_file, -min(30, strlen($relative_file))), $stat['status_code'], count($stat['output'][0]['stats']['failed']) + count($stat['output'][0]['stats']['passed']), count($stat['output'][0]['stats']['failed']), count($stat['output'][0]['stats']['errors']), implode(' ', $stat['output'][0]['stats']['failed'])));
1128+
$this->output->echoln(sprintf($format,
1129+
substr($relative_file, -min(30, strlen($relative_file))),
1130+
$stat['status_code'],
1131+
count($stat['output'][0]['stats']['failed'])
1132+
+ count($stat['output'][0]['stats']['passed']),
1133+
count($stat['output'][0]['stats']['failed']),
1134+
count($stat['output'][0]['stats']['errors']),
1135+
implode(' ', $stat['output'][0]['stats']['failed'])
1136+
));
11291137
}
11301138
else
11311139
{

test/unit/vendor/lime/limeTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct()
4343
}
4444
}
4545

46-
$test = new lime_test(20);
46+
$test = new lime_test(22);
4747

4848
$files = [
4949
__DIR__.'/fixtures/failed.php',
@@ -128,6 +128,16 @@ public function __construct()
128128
$message = 'with at least one thrown Exception will fail the overall test suite';
129129
whenExecuteHarnessWithFilesWillHaveResultAndOutput($test, $files, $expectedOverallSucceed, $expectedOutput, $message);
130130

131+
$files = [__DIR__.'/fixtures/pass.php'];
132+
$expectedOverallSucceed = true;
133+
$expectedOutput = <<<'EOF'
134+
test/unit/vendor/lime/fixtures/pass..................................ok
135+
All tests successful.
136+
Files=1, Tests=1
137+
138+
EOF;
139+
$message = 'with all tests passes without error or exception will succeed the overall test suite';
140+
whenExecuteHarnessWithFilesWillHaveResultAndOutput($test, $files, $expectedOverallSucceed, $expectedOutput, $message);
131141

132142
$name = 'pass';
133143
$expectedStatusCode = 0;

0 commit comments

Comments
 (0)