1
0
Fork 0

Only treat errors as real failures, fixes #5601

pull/5503/merge
Jordi Boggiano 2016-09-12 11:00:38 +02:00
parent cfdeb61779
commit b29d810d63
1 changed files with 30 additions and 11 deletions

View File

@ -385,22 +385,41 @@ EOT
private function outputResult($result)
{
$io = $this->getIO();
$hadError = false;
if (true === $result) {
$io->write('<info>OK</info>');
} else {
$this->failures++;
$io->write('<error>FAIL</error>');
return;
}
if ($result instanceof \Exception) {
$io->write('['.get_class($result).'] '.$result->getMessage());
} elseif ($result) {
if (is_array($result)) {
$result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
}
if (!$result) {
// falsey results should be considered as an error, even if there is nothing to output
$hadError = true;
} else {
if (!is_array($result)) {
$result = array($result);
}
foreach ($result as $message) {
if (false !== strpos($message, '<error>')) {
$hadError = true;
}
}
}
if ($hadError) {
$io->write('<error>FAIL</error>');
$this->failures++;
} else {
$io->write('<warning>WARNING</warning>');
}
if ($result) {
foreach ($result as $message) {
$io->write($message);
}
} else {
$io->write($result);
}
}
}
}