2014-02-27 11:06:37 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialUnitField
|
2016-02-29 09:53:46 -08:00
|
|
|
extends DifferentialCustomField {
|
2014-02-27 11:06:37 -08:00
|
|
|
|
|
|
|
public function getFieldKey() {
|
|
|
|
return 'differential:unit';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldName() {
|
|
|
|
return pht('Unit');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldDescription() {
|
|
|
|
return pht('Shows unit test results.');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInPropertyView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-06-16 08:53:40 -07:00
|
|
|
public function renderPropertyViewValue(array $handles) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldAppearInDiffPropertyView() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
|
2014-02-27 11:06:37 -08:00
|
|
|
return $this->getFieldName();
|
|
|
|
}
|
|
|
|
|
2014-03-09 13:18:17 -07:00
|
|
|
public function getWarningsForDetailView() {
|
|
|
|
$warnings = array();
|
2017-01-04 14:05:25 -08:00
|
|
|
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$diff = $this->getObject()->getActiveDiff();
|
|
|
|
|
|
|
|
$buildable = id(new HarbormasterBuildableQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withBuildablePHIDs(array($diff->getPHID()))
|
|
|
|
->withManualBuildables(false)
|
|
|
|
->executeOne();
|
|
|
|
if ($buildable) {
|
|
|
|
switch ($buildable->getBuildableStatus()) {
|
2018-02-12 10:55:19 -08:00
|
|
|
case HarbormasterBuildableStatus::STATUS_BUILDING:
|
2017-01-04 14:05:25 -08:00
|
|
|
$warnings[] = pht(
|
|
|
|
'These changes have not finished building yet and may have build '.
|
|
|
|
'failures.');
|
|
|
|
break;
|
2018-02-12 10:55:19 -08:00
|
|
|
case HarbormasterBuildableStatus::STATUS_FAILED:
|
2017-01-04 14:05:25 -08:00
|
|
|
$warnings[] = pht(
|
|
|
|
'These changes have failed to build.');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$status = $this->getObject()->getActiveDiff()->getUnitStatus();
|
2014-03-09 13:18:17 -07:00
|
|
|
if ($status < DifferentialUnitStatus::UNIT_WARN) {
|
|
|
|
// Don't show any warnings.
|
2014-09-16 12:11:54 -07:00
|
|
|
} else if ($status == DifferentialUnitStatus::UNIT_AUTO_SKIP) {
|
|
|
|
// Don't show any warnings.
|
2014-03-09 13:18:17 -07:00
|
|
|
} else if ($status == DifferentialUnitStatus::UNIT_SKIP) {
|
|
|
|
$warnings[] = pht(
|
|
|
|
'Unit tests were skipped when generating these changes.');
|
|
|
|
} else {
|
|
|
|
$warnings[] = pht('These changes have unit test problems.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $warnings;
|
|
|
|
}
|
|
|
|
|
2016-02-29 09:53:46 -08:00
|
|
|
public function renderDiffPropertyViewValue(DifferentialDiff $diff) {
|
2014-03-09 13:18:17 -07:00
|
|
|
|
2015-06-21 10:37:55 -07:00
|
|
|
$colors = array(
|
|
|
|
DifferentialUnitStatus::UNIT_NONE => 'grey',
|
|
|
|
DifferentialUnitStatus::UNIT_OKAY => 'green',
|
|
|
|
DifferentialUnitStatus::UNIT_WARN => 'yellow',
|
|
|
|
DifferentialUnitStatus::UNIT_FAIL => 'red',
|
|
|
|
DifferentialUnitStatus::UNIT_SKIP => 'blue',
|
|
|
|
DifferentialUnitStatus::UNIT_AUTO_SKIP => 'blue',
|
|
|
|
);
|
|
|
|
$icon_color = idx($colors, $diff->getUnitStatus(), 'grey');
|
|
|
|
|
2016-09-02 10:16:14 -07:00
|
|
|
$message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage(
|
|
|
|
$diff->getUnitStatus());
|
2015-06-21 10:37:55 -07:00
|
|
|
|
|
|
|
$status = id(new PHUIStatusListView())
|
|
|
|
->addItem(
|
|
|
|
id(new PHUIStatusItemView())
|
|
|
|
->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color)
|
2016-02-29 09:53:46 -08:00
|
|
|
->setTarget($message));
|
2015-06-21 10:37:55 -07:00
|
|
|
|
|
|
|
return $status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-27 11:06:37 -08:00
|
|
|
}
|