1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 23:02:41 +01:00

Publicize formatting unit test result

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
This commit is contained in:
vrana 2012-09-13 13:25:26 -07:00
parent fefa9e2d72
commit ac7b9e42d6
2 changed files with 16 additions and 17 deletions

View 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;

View 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));
}