Page MenuHomePhabricator

D11690.diff
No OneTemporary

D11690.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -184,6 +184,7 @@
'ArcanistTodoWorkflow' => 'workflow/ArcanistTodoWorkflow.php',
'ArcanistUncommittedChangesException' => 'exception/usage/ArcanistUncommittedChangesException.php',
'ArcanistUnitConsoleRenderer' => 'unit/renderer/ArcanistUnitConsoleRenderer.php',
+ 'ArcanistUnitJSONRealtimeRenderer' => 'unit/renderer/ArcanistUnitJSONRealtimeRenderer.php',
'ArcanistUnitRenderer' => 'unit/renderer/ArcanistUnitRenderer.php',
'ArcanistUnitTestEngine' => 'unit/engine/ArcanistUnitTestEngine.php',
'ArcanistUnitTestResult' => 'unit/ArcanistUnitTestResult.php',
@@ -366,6 +367,7 @@
'ArcanistTodoWorkflow' => 'ArcanistWorkflow',
'ArcanistUncommittedChangesException' => 'ArcanistUsageException',
'ArcanistUnitConsoleRenderer' => 'ArcanistUnitRenderer',
+ 'ArcanistUnitJSONRealtimeRenderer' => 'ArcanistUnitRenderer',
'ArcanistUnitTestableLintEngine' => 'ArcanistLintEngine',
'ArcanistUnitWorkflow' => 'ArcanistWorkflow',
'ArcanistUpgradeWorkflow' => 'ArcanistWorkflow',
diff --git a/src/unit/renderer/ArcanistUnitJSONRealtimeRenderer.php b/src/unit/renderer/ArcanistUnitJSONRealtimeRenderer.php
new file mode 100644
--- /dev/null
+++ b/src/unit/renderer/ArcanistUnitJSONRealtimeRenderer.php
@@ -0,0 +1,13 @@
+<?php
+
+final class ArcanistUnitJSONRealtimeRenderer extends ArcanistUnitRenderer {
+
+ public function renderUnitResult(ArcanistUnitTestResult $result) {
+ return '##arc-unit## '.json_encode($result->toDictionary())."\n";
+ }
+
+ public function renderPostponedResult($count) {
+ return null;
+ }
+
+}
diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php
--- a/src/workflow/ArcanistUnitWorkflow.php
+++ b/src/workflow/ArcanistUnitWorkflow.php
@@ -75,6 +75,9 @@
'help' =>
"With 'full', show full pretty report (Default). ".
"With 'json', report results in JSON format. ".
+ "With 'json-realtime', report results in JSON format as ".
+ "test results occur (JSON entries separated by newlines ".
+ "and prefixed with '##arc-unit## '). ".
"With 'ugly', use uglier (but more efficient) JSON formatting. ".
"With 'none', don't print results. ",
'conflicts' => array(
@@ -153,7 +156,13 @@
}
$this->engine->setArguments($this->getPassthruArgumentsAsMap('unit'));
- $renderer = new ArcanistUnitConsoleRenderer();
+ $output_format = $this->getOutputFormat();
+
+ if ($output_format === 'json-realtime') {
+ $renderer = new ArcanistUnitJSONRealtimeRenderer();
+ } else {
+ $renderer = new ArcanistUnitConsoleRenderer();
+ }
$this->engine->setRenderer($renderer);
$enable_coverage = null; // Means "default".
@@ -177,9 +186,7 @@
$console = PhutilConsole::getConsole();
- $output_format = $this->getOutputFormat();
-
- if ($output_format !== 'full') {
+ if ($output_format !== 'full' && $output_format !== 'json-realtime') {
$console->disableOut();
}
@@ -268,7 +275,7 @@
}
}
- if ($output_format !== 'full') {
+ if ($output_format !== 'full' && $output_format !== 'json-realtime') {
$console->enableOut();
}
$data = array_values(mpull($results, 'toDictionary'));
@@ -351,6 +358,7 @@
$known_formats = array(
'none' => 'none',
'json' => 'json',
+ 'json-realtime' => 'json-realtime',
'ugly' => 'ugly',
'full' => 'full',
);

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 10:18 PM (3 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276462
Default Alt Text
D11690.diff (3 KB)

Event Timeline