]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Publicize formatting unit test result
authorvrana <jakubv@fb.com>
Thu, 13 Sep 2012 20:25:26 +0000 (13:25 -0700)
committervrana <jakubv@fb.com>
Fri, 14 Sep 2012 05:36:46 +0000 (22:36 -0700)
Summary: I want to use it from outside.

Test Plan:
  $ arc unit src/lint/linter/__tests__/

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D3493

src/unit/ArcanistUnitTestResult.php
src/workflow/ArcanistUnitWorkflow.php

index a30789c244183c6eb598f5be7d4a01ffcef47197..3b43f60a94958c7722c7452e2ee7946c7d7b2583 100644 (file)
@@ -66,6 +66,18 @@ final class ArcanistUnitTestResult {
     return $this->result;
   }
 
+  public function getConsoleFormattedResult() {
+    static $status_codes = array(
+      self::RESULT_PASS => '<bg:green>** PASS **</bg>',
+      self::RESULT_FAIL => '<bg:red>** FAIL **</bg>',
+      self::RESULT_SKIP => '<bg:yellow>** SKIP **</bg>',
+      self::RESULT_BROKEN => '<bg:red>** BROKEN **</bg>',
+      self::RESULT_UNSOUND => '<bg:yellow>** UNSOUND **</bg>',
+      self::RESULT_POSTPONED => '<bg:yellow>** POSTPONED **</bg>',
+    );
+    return phutil_console_format($status_codes[$this->result]);
+  }
+
   public function setDuration($duration) {
     $this->duration = $duration;
     return $this;
index c4eb2e8567eb7880dd6c897df0a194dac1859317..692580c16261cc0490247de1d7ee577772533801 100644 (file)
@@ -147,21 +147,6 @@ EOTEXT
     $results = $this->engine->run();
     $this->testResults = $results;
 
-    $status_codes = array(
-      ArcanistUnitTestResult::RESULT_PASS => phutil_console_format(
-        '<bg:green>** PASS **</bg>'),
-      ArcanistUnitTestResult::RESULT_FAIL => phutil_console_format(
-        '<bg:red>** FAIL **</bg>'),
-      ArcanistUnitTestResult::RESULT_SKIP => phutil_console_format(
-        '<bg:yellow>** SKIP **</bg>'),
-      ArcanistUnitTestResult::RESULT_BROKEN => phutil_console_format(
-        '<bg:red>** BROKEN **</bg>'),
-      ArcanistUnitTestResult::RESULT_UNSOUND => phutil_console_format(
-        '<bg:yellow>** UNSOUND **</bg>'),
-      ArcanistUnitTestResult::RESULT_POSTPONED => phutil_console_format(
-        '<bg:yellow>** POSTPONED **</bg>'),
-      );
-
     $console = PhutilConsole::getConsole();
 
     $unresolved = array();
@@ -180,7 +165,7 @@ EOTEXT
           }
           $console->writeOut(
             "  %s %s\n",
-            $status_codes[$result_code].$duration,
+            $result->getConsoleFormattedResult().$duration,
             $result->getName());
         }
         if ($result_code != ArcanistUnitTestResult::RESULT_PASS) {
@@ -197,9 +182,11 @@ EOTEXT
       }
     }
     if ($postponed_count) {
+      $postponed = id(new ArcanistUnitTestResult())
+        ->setResult(ArcanistUnitTestResult::RESULT_POSTPONED);
       $console->writeOut(
         "%s %s\n",
-        $status_codes[ArcanistUnitTestResult::RESULT_POSTPONED],
+        $postponed->getConsoleFormattedResult(),
         pht('%d test(s)', $postponed_count));
     }