Skip to content

Commit

Permalink
fix(test): exit code of lime test
Browse files Browse the repository at this point in the history
  • Loading branch information
alquerci committed Mar 4, 2024
1 parent edb850f commit 136b3c1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/vendor/lime/lime.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ class lime_test
protected $options = array();

static protected $all_results = array();
static private $instanceCount = 0;
static private $allExitCode = 0;

public function __construct($plan = null, $options = array())
{
++self::$instanceCount;

// for BC
if (!is_array($options))
{
Expand Down Expand Up @@ -130,6 +134,8 @@ static public function to_xml($results = null)

public function __destruct()
{
--self::$instanceCount;

$plan = $this->results['stats']['plan'];
$passed = count($this->results['stats']['passed']);
$failed = count($this->results['stats']['failed']);
Expand All @@ -155,6 +161,31 @@ public function __destruct()
}

flush();

self::$allExitCode |= $this->getExitCode();

if (0 === self::$instanceCount) {
exit(self::$allExitCode);
}
}

private function getExitCode()
{
$plan = $this->results['stats']['plan'];
$failed = count($this->results['stats']['failed']);
$total = $this->results['stats']['total'];
is_null($plan) and $plan = $total and $this->output->echoln(sprintf("1..%d", $plan));

if ($failed)
{
return 1;
}
else if ($total == $plan)
{
return 0;
}

return 1;
}

/**
Expand Down

0 comments on commit 136b3c1

Please sign in to comment.