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 authored and thePanz committed Jan 17, 2024
1 parent b88d698 commit 05ac333
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 @@ -25,9 +25,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 @@ -131,6 +135,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 @@ -156,6 +162,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 05ac333

Please sign in to comment.