Changeset View
Changeset View
Standalone View
Standalone View
src/unit/ArcanistUnitTestResult.php
| Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | return array( | ||||
| 'duration' => $this->getDuration(), | 'duration' => $this->getDuration(), | ||||
| 'extra' => $this->getExtraData(), | 'extra' => $this->getExtraData(), | ||||
| 'userData' => $this->getUserData(), | 'userData' => $this->getUserData(), | ||||
| 'coverage' => $this->getCoverage(), | 'coverage' => $this->getCoverage(), | ||||
| ); | ); | ||||
| } | } | ||||
| public static function getAllResultCodes() { | public static function getAllResultCodes() { | ||||
| return array( | $map = self::getResultCodeSpecs(); | ||||
| self::RESULT_PASS, | return array_keys($map); | ||||
| self::RESULT_FAIL, | |||||
| self::RESULT_SKIP, | |||||
| self::RESULT_BROKEN, | |||||
| self::RESULT_UNSOUND, | |||||
| ); | |||||
| } | } | ||||
| public static function getResultCodeName($result_code) { | public static function getResultCodeName($result_code) { | ||||
| $spec = self::getResultCodeSpec($result_code); | $spec = self::getResultCodeSpec($result_code); | ||||
| if (!$spec) { | if (!$spec) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return idx($spec, 'name'); | return idx($spec, 'name'); | ||||
| } | } | ||||
| public static function getResultCodeDescription($result_code) { | public static function getResultCodeDescription($result_code) { | ||||
| $spec = self::getResultCodeSpec($result_code); | $spec = self::getResultCodeSpec($result_code); | ||||
| if (!$spec) { | if (!$spec) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| return idx($spec, 'description'); | return idx($spec, 'description'); | ||||
| } | } | ||||
| private static function getResultCodeSpec($result_code) { | private static function getResultCodeSpec($result_code) { | ||||
| $specs = self::getResultCodeSpecs(); | $specs = self::getResultCodeSpecs(); | ||||
| return idx($specs, $result_code); | return idx($specs, $result_code); | ||||
| } | } | ||||
| public function getANSIColor() { | |||||
| $spec = $this->getResultMap(); | |||||
| return idx($spec, 'color.ansi', 'red'); | |||||
| } | |||||
| public function getResultLabel() { | |||||
| $spec = $this->getResultMap(); | |||||
| return idx($spec, 'label', $this->getResult()); | |||||
| } | |||||
| private function getResultMap() { | |||||
| $map = self::getResultCodeSpecs(); | |||||
| return idx($map, $this->getResult(), array()); | |||||
| } | |||||
| private static function getResultCodeSpecs() { | private static function getResultCodeSpecs() { | ||||
| return array( | return array( | ||||
| self::RESULT_PASS => array( | self::RESULT_PASS => array( | ||||
| 'name' => pht('Pass'), | 'name' => pht('Pass'), | ||||
| 'label' => pht('PASS'), | |||||
| 'color.ansi' => 'green', | |||||
| 'description' => pht( | 'description' => pht( | ||||
| 'The test passed.'), | 'The test passed.'), | ||||
| ), | ), | ||||
| self::RESULT_FAIL => array( | self::RESULT_FAIL => array( | ||||
| 'name' => pht('Fail'), | 'name' => pht('Fail'), | ||||
| 'label' => pht('FAIL'), | |||||
| 'color.ansi' => 'red', | |||||
| 'description' => pht( | 'description' => pht( | ||||
| 'The test failed.'), | 'The test failed.'), | ||||
| ), | ), | ||||
| self::RESULT_SKIP => array( | self::RESULT_SKIP => array( | ||||
| 'name' => pht('Skip'), | 'name' => pht('Skip'), | ||||
| 'label' => pht('SKIP'), | |||||
| 'color.ansi' => 'cyan', | |||||
| 'description' => pht( | 'description' => pht( | ||||
| 'The test was not executed.'), | 'The test was not executed.'), | ||||
| ), | ), | ||||
| self::RESULT_BROKEN => array( | self::RESULT_BROKEN => array( | ||||
| 'name' => pht('Broken'), | 'name' => pht('Broken'), | ||||
| 'label' => pht('BROKEN'), | |||||
| 'color.ansi' => 'red', | |||||
| 'description' => pht( | 'description' => pht( | ||||
| 'The test failed in an abnormal or severe way. For example, the '. | 'The test failed in an abnormal or severe way. For example, the '. | ||||
| 'harness crashed instead of reporting a failure.'), | 'harness crashed instead of reporting a failure.'), | ||||
| ), | ), | ||||
| self::RESULT_UNSOUND => array( | self::RESULT_UNSOUND => array( | ||||
| 'name' => pht('Unsound'), | 'name' => pht('Unsound'), | ||||
| 'label' => pht('UNSOUND'), | |||||
| 'color.ansi' => 'yellow', | |||||
| 'description' => pht( | 'description' => pht( | ||||
| 'The test failed, but this change is probably not what broke it. '. | 'The test failed, but this change is probably not what broke it. '. | ||||
| 'For example, it might have already been failing.'), | 'For example, it might have already been failing.'), | ||||
| ), | ), | ||||
| ); | ); | ||||
| } | } | ||||
| public function getDisplayName() { | |||||
| $name = $this->getName(); | |||||
| $namespace = $this->getNamespace(); | |||||
| if (strlen($namespace)) { | |||||
| $name = $namespace.'::'.$name; | |||||
| } | |||||
| return $name; | |||||
| } | |||||
| } | } | ||||