Changeset View
Changeset View
Standalone View
Standalone View
src/unit/renderer/ArcanistUnitConsoleRenderer.php
| Show All 30 Lines | final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer { | ||||
| public function renderPostponedResult($count) { | public function renderPostponedResult($count) { | ||||
| return sprintf( | return sprintf( | ||||
| "%s %s\n", | "%s %s\n", | ||||
| $this->getFormattedResult(ArcanistUnitTestResult::RESULT_POSTPONED), | $this->getFormattedResult(ArcanistUnitTestResult::RESULT_POSTPONED), | ||||
| pht('%d test(s)', $count)); | pht('%d test(s)', $count)); | ||||
| } | } | ||||
| private function getFormattedResult($result) { | private function getFormattedResult($result) { | ||||
| static $status_codes = array( | switch ($result) { | ||||
| ArcanistUnitTestResult::RESULT_PASS => '<bg:green>** PASS **</bg>', | case ArcanistUnitTestResult::RESULT_PASS: | ||||
| ArcanistUnitTestResult::RESULT_FAIL => '<bg:red>** FAIL **</bg>', | return phutil_console_format('<bg:green>** %s **</bg>', pht('PASS')); | ||||
| ArcanistUnitTestResult::RESULT_SKIP => '<bg:yellow>** SKIP **</bg>', | |||||
| ArcanistUnitTestResult::RESULT_BROKEN => '<bg:red>** BROKEN **</bg>', | case ArcanistUnitTestResult::RESULT_FAIL: | ||||
| ArcanistUnitTestResult::RESULT_UNSOUND => '<bg:yellow>** UNSOUND **</bg>', | return phutil_console_format('<bg:red>** %s **</bg>', pht('FAIL')); | ||||
| ArcanistUnitTestResult::RESULT_POSTPONED => | |||||
| '<bg:yellow>** POSTPONED **</bg>', | case ArcanistUnitTestResult::RESULT_SKIP: | ||||
| ); | return phutil_console_format('<bg:yellow>** %s **</bg>', pht('SKIP')); | ||||
| return phutil_console_format($status_codes[$result]); | |||||
| case ArcanistUnitTestResult::RESULT_BROKEN: | |||||
| return phutil_console_format('<bg:red>** %s **</bg>', pht('BROKEN')); | |||||
| case ArcanistUnitTestResult::RESULT_UNSOUND: | |||||
| return phutil_console_format( | |||||
| '<bg:yellow>** %s **</bg>', | |||||
| pht('UNSOUND')); | |||||
| case ArcanistUnitTestResult::RESULT_POSTPONED: | |||||
| return phutil_console_format( | |||||
| '<bg:yellow>** %s **</bg>', | |||||
| pht('POSTPONED')); | |||||
| default: | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| private function formatTestDuration($seconds) { | private function formatTestDuration($seconds) { | ||||
| // Very carefully define inclusive upper bounds on acceptable unit test | // Very carefully define inclusive upper bounds on acceptable unit test | ||||
| // durations. Times are in milliseconds and are in increasing order. | // durations. Times are in milliseconds and are in increasing order. | ||||
| $star = "\xE2\x98\x85"; | $star = "\xE2\x98\x85"; | ||||
| if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
| // Fall-back to normal asterisk for Windows consoles. | // Fall-back to normal asterisk for Windows consoles. | ||||
| Show All 38 Lines | |||||