Skip to content

Commit fa11b69

Browse files
committed
Revert "fixup! fix(test): exit code of lime test"
This reverts commit 8d951e2a5b1a8cf958f351a2d305a8c5007bad29.
1 parent f25c0cd commit fa11b69

File tree

3 files changed

+20
-89
lines changed

3 files changed

+20
-89
lines changed

lib/plugins/sfDoctrinePlugin/test/bin/coverage.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,4 @@
3232

3333
$finder = sfFinder::type('file')->name('*.php')->prune('vendor')->prune('test')->prune('data');
3434
$c->register($finder->in($c->base_dir));
35-
36-
$allTestsSucceed = $c->run();
37-
38-
exit($allTestsSucceed ? 0 : 1);
35+
$c->run();

lib/vendor/lime/lime.php

Lines changed: 18 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,17 @@
1616
*/
1717
class lime_test
1818
{
19-
public const EPSILON = 0.0000000001;
19+
const EPSILON = 0.0000000001;
2020

2121
protected $test_nb = 0;
2222
protected $output = null;
2323
protected $results = array();
2424
protected $options = array();
2525

26-
protected static $all_results = array();
27-
28-
private const STATE_PASS = 0;
29-
private const STATE_FAIL = 1;
30-
31-
private static $instanceCount = 0;
32-
private static $finalState = self::STATE_PASS;
26+
static protected $all_results = array();
3327

3428
public function __construct($plan = null, $options = array())
3529
{
36-
++self::$instanceCount;
37-
3830
// for BC
3931
if (!is_array($options))
4032
{
@@ -137,87 +129,32 @@ static public function to_xml($results = null)
137129
}
138130

139131
public function __destruct()
140-
{
141-
$testSuiteState = $this->determineAndPrintStateOfTestSuite();
142-
143-
flush();
144-
145-
$this->keepTheWorstState($testSuiteState);
146-
147-
$this->finalizeLastInstanceDestructorWithProcessExit();
148-
}
149-
150-
private function determineAndPrintStateOfTestSuite(): int
151-
{
152-
$planState = $this->determineAndPrintStateOfPlan();
153-
$failed = count($this->results['stats']['failed']);
154-
155-
if ($failed) {
156-
$passed = count($this->results['stats']['passed']);
157-
158-
$this->output->red_bar(sprintf("# Looks like you failed %d tests of %d.", $failed, $passed + $failed));
159-
160-
return self::STATE_FAIL;
161-
}
162-
163-
if (self::STATE_FAIL === $planState) {
164-
return self::STATE_FAIL;
165-
}
166-
167-
$this->output->green_bar("# Looks like everything went fine.");
168-
169-
return self::STATE_PASS;
170-
}
171-
172-
private function determineAndPrintStateOfPlan(): int
173132
{
174133
$plan = $this->results['stats']['plan'];
134+
$passed = count($this->results['stats']['passed']);
135+
$failed = count($this->results['stats']['failed']);
175136
$total = $this->results['stats']['total'];
137+
is_null($plan) and $plan = $total and $this->output->echoln(sprintf("1..%d", $plan));
176138

177-
if (null === $plan) {
178-
$plan = $total;
179-
180-
$this->output->echoln(sprintf("1..%d", $plan));
181-
}
182-
183-
if ($total > $plan) {
139+
if ($total > $plan)
140+
{
184141
$this->output->red_bar(sprintf("# Looks like you planned %d tests but ran %d extra.", $plan, $total - $plan));
185-
} elseif ($total < $plan) {
142+
}
143+
elseif ($total < $plan)
144+
{
186145
$this->output->red_bar(sprintf("# Looks like you planned %d tests but only ran %d.", $plan, $total));
187146
}
188147

189-
return $total === $plan ? self::STATE_PASS : self::STATE_FAIL;
190-
}
191-
192-
private function keepTheWorstState(int $state): void
193-
{
194-
if ($this->stateIsTheWorst($state)) {
195-
self::$finalState = $state;
148+
if ($failed)
149+
{
150+
$this->output->red_bar(sprintf("# Looks like you failed %d tests of %d.", $failed, $passed + $failed));
196151
}
197-
}
198-
199-
private function stateIsTheWorst(int $state): bool
200-
{
201-
return self::$finalState < $state;
202-
}
203-
204-
private function finalizeLastInstanceDestructorWithProcessExit(): void
205-
{
206-
--self::$instanceCount;
207-
208-
if (0 === self::$instanceCount) {
209-
exit($this->determineExitCodeFromState(self::$finalState));
152+
else if ($total == $plan)
153+
{
154+
$this->output->green_bar("# Looks like everything went fine.");
210155
}
211-
}
212156

213-
private function determineExitCodeFromState(int $state): int
214-
{
215-
switch ($state) {
216-
case self::STATE_PASS:
217-
return 0;
218-
default:
219-
return 1;
220-
}
157+
flush();
221158
}
222159

223160
/**
@@ -1032,7 +969,7 @@ function lime_shutdown()
1032969
$delta = 0;
1033970
if ($return > 0)
1034971
{
1035-
$stats['status'] = $file_stats['failed'] ? 'not ok' : ($file_stats['errors'] ? 'errors' : 'dubious');
972+
$stats['status'] = $file_stats['errors'] ? 'errors' : 'dubious';
1036973
$stats['status_code'] = $return;
1037974
}
1038975
else

test/bin/coverage.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@
4242
$finder = sfFinder::type('file')->name($name.'.class.php')->prune('vendor')->prune('test')->prune('data');
4343

4444
$c->register($finder->in($c->base_dir));
45-
46-
$allTestsSucceed = $c->run();
47-
48-
exit($allTestsSucceed ? 0 : 1);
45+
$c->run();

0 commit comments

Comments
 (0)