浏览代码

Only treat errors as real failures, fixes #5601

Jordi Boggiano 8 年之前
父节点
当前提交
b29d810d63
共有 1 个文件被更改,包括 30 次插入11 次删除
  1. 30 11
      src/Composer/Command/DiagnoseCommand.php

+ 30 - 11
src/Composer/Command/DiagnoseCommand.php

@@ -385,23 +385,42 @@ EOT
     private function outputResult($result)
     private function outputResult($result)
     {
     {
         $io = $this->getIO();
         $io = $this->getIO();
+        $hadError = false;
         if (true === $result) {
         if (true === $result) {
             $io->write('<info>OK</info>');
             $io->write('<info>OK</info>');
+            return;
+        }
+
+        if ($result instanceof \Exception) {
+            $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 {
         } else {
-            $this->failures++;
-            $io->write('<error>FAIL</error>');
-            if ($result instanceof \Exception) {
-                $io->write('['.get_class($result).'] '.$result->getMessage());
-            } elseif ($result) {
-                if (is_array($result)) {
-                    foreach ($result as $message) {
-                        $io->write($message);
-                    }
-                } else {
-                    $io->write($result);
+            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);
+            }
+        }
     }
     }
 
 
     private function checkPlatform()
     private function checkPlatform()