mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-10 00:42:40 +01:00
Add a --target flag to arc unit
for uploading results
Summary: Ref T5821. Basic idea here is that Harbormaster can run `arc unit --everything --target ...` to get a build target updated. Test Plan: Ran `arc unit --target ...`, saw web UI update with test results. Reviewers: chad Reviewed By: chad Maniphest Tasks: T5821 Differential Revision: https://secure.phabricator.com/D14190
This commit is contained in:
parent
2df96ed405
commit
d3abb65572
3 changed files with 82 additions and 28 deletions
|
@ -2753,15 +2753,7 @@ EOTEXT
|
|||
$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 @@ EOTEXT
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,6 +84,12 @@ EOTEXT
|
|||
'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 @@ EOTEXT
|
|||
return true;
|
||||
}
|
||||
|
||||
public function requiresConduit() {
|
||||
return $this->shouldUploadResults();
|
||||
}
|
||||
|
||||
public function requiresAuthentication() {
|
||||
return $this->shouldUploadResults();
|
||||
}
|
||||
|
||||
public function getEngine() {
|
||||
return $this->engine;
|
||||
}
|
||||
|
@ -263,6 +277,12 @@ EOTEXT
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
$target_phid = $this->getArgument('target');
|
||||
if ($target_phid) {
|
||||
$this->uploadTestResults($target_phid, $overall_result, $results);
|
||||
}
|
||||
|
||||
return $overall_result;
|
||||
}
|
||||
|
||||
|
@ -370,4 +390,46 @@ EOTEXT
|
|||
|
||||
}
|
||||
|
||||
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,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2040,5 +2040,24 @@ abstract class ArcanistWorkflow extends Phobject {
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue