Page MenuHomePhabricator

D14190.diff
No OneTemporary

D14190.diff

diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php
--- a/src/workflow/ArcanistDiffWorkflow.php
+++ b/src/workflow/ArcanistDiffWorkflow.php
@@ -2753,15 +2753,7 @@
$unit[$key] = $this->getModernUnitDictionary($message);
}
- switch ($unit_result) {
- case ArcanistUnitWorkflow::RESULT_OKAY:
- case ArcanistUnitWorkflow::RESULT_SKIP:
- $type = 'pass';
- break;
- default:
- $type = 'fail';
- break;
- }
+ $type = ArcanistUnitWorkflow::getHarbormasterTypeFromResult($unit_result);
$futures[] = $this->getConduit()->callMethod(
'harbormaster.sendmessage',
@@ -2785,23 +2777,4 @@
}
}
- private function getModernLintDictionary(array $map) {
- $map = $this->getModernCommonDictionary($map);
- return $map;
- }
-
- private function getModernUnitDictionary(array $map) {
- $map = $this->getModernCommonDictionary($map);
- return $map;
- }
-
- private function getModernCommonDictionary(array $map) {
- foreach ($map as $key => $value) {
- if ($value === null) {
- unset($map[$key]);
- }
- }
- return $map;
- }
-
}
diff --git a/src/workflow/ArcanistUnitWorkflow.php b/src/workflow/ArcanistUnitWorkflow.php
--- a/src/workflow/ArcanistUnitWorkflow.php
+++ b/src/workflow/ArcanistUnitWorkflow.php
@@ -84,6 +84,12 @@
'ugly' => pht('Only one output format allowed'),
),
),
+ 'target' => array(
+ 'param' => 'phid',
+ 'help' => pht(
+ '(PROTOTYPE) Record a copy of the test results on the specified '.
+ 'Harbormaster build target.'),
+ ),
'everything' => array(
'help' => pht('Run every test.'),
'conflicts' => array(
@@ -107,6 +113,14 @@
return true;
}
+ public function requiresConduit() {
+ return $this->shouldUploadResults();
+ }
+
+ public function requiresAuthentication() {
+ return $this->shouldUploadResults();
+ }
+
public function getEngine() {
return $this->engine;
}
@@ -263,6 +277,12 @@
break;
}
+
+ $target_phid = $this->getArgument('target');
+ if ($target_phid) {
+ $this->uploadTestResults($target_phid, $overall_result, $results);
+ }
+
return $overall_result;
}
@@ -370,4 +390,46 @@
}
+ public static function getHarbormasterTypeFromResult($unit_result) {
+ switch ($unit_result) {
+ case self::RESULT_OKAY:
+ case self::RESULT_SKIP:
+ $type = 'pass';
+ break;
+ default:
+ $type = 'fail';
+ break;
+ }
+
+ return $type;
+ }
+
+ private function shouldUploadResults() {
+ return ($this->getArgument('target') !== null);
+ }
+
+ private function uploadTestResults(
+ $target_phid,
+ $unit_result,
+ array $unit) {
+
+ // TODO: It would eventually be nice to stream test results up to the
+ // server as we go, but just get things working for now.
+
+ $message_type = self::getHarbormasterTypeFromResult($unit_result);
+
+ foreach ($unit as $key => $result) {
+ $dictionary = $result->toDictionary();
+ $unit[$key] = $this->getModernUnitDictionary($dictionary);
+ }
+
+ $this->getConduit()->callMethodSynchronous(
+ 'harbormaster.sendmessage',
+ array(
+ 'buildTargetPHID' => $target_phid,
+ 'unit' => array_values($unit),
+ 'type' => $message_type,
+ ));
+ }
+
}
diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php
--- a/src/workflow/ArcanistWorkflow.php
+++ b/src/workflow/ArcanistWorkflow.php
@@ -2040,5 +2040,24 @@
}
}
+ protected function getModernLintDictionary(array $map) {
+ $map = $this->getModernCommonDictionary($map);
+ return $map;
+ }
+
+ protected function getModernUnitDictionary(array $map) {
+ $map = $this->getModernCommonDictionary($map);
+ return $map;
+ }
+
+ private function getModernCommonDictionary(array $map) {
+ foreach ($map as $key => $value) {
+ if ($value === null) {
+ unset($map[$key]);
+ }
+ }
+ return $map;
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 22, 11:00 AM (3 h, 5 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7025885
Default Alt Text
D14190.diff (4 KB)

Event Timeline