Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/customfield/DifferentialUnitField.php
Show All 26 Lines | public function shouldAppearInDiffPropertyView() { | ||||
return true; | return true; | ||||
} | } | ||||
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { | public function renderDiffPropertyViewLabel(DifferentialDiff $diff) { | ||||
return $this->getFieldName(); | return $this->getFieldName(); | ||||
} | } | ||||
public function getWarningsForDetailView() { | public function getWarningsForDetailView() { | ||||
$status = $this->getObject()->getActiveDiff()->getUnitStatus(); | $active_diff = $this->getObject()->getActiveDiff(); | ||||
$status = $active_diff->getSummaryUnitStatus(); | |||||
$warnings = array(); | $warnings = array(); | ||||
if ($status < DifferentialUnitStatus::UNIT_WARN) { | if ($status < DifferentialUnitStatus::UNIT_WARN) { | ||||
// Don't show any warnings. | // Don't show any warnings. | ||||
} else if ($status == DifferentialUnitStatus::UNIT_AUTO_SKIP) { | } else if ($status == DifferentialUnitStatus::UNIT_AUTO_SKIP) { | ||||
// Don't show any warnings. | // Don't show any warnings. | ||||
} else if ($status == DifferentialUnitStatus::UNIT_SKIP) { | } else if ($status == DifferentialUnitStatus::UNIT_SKIP) { | ||||
$warnings[] = pht( | $warnings[] = pht( | ||||
'Unit tests were skipped when generating these changes.'); | 'Unit tests were skipped when generating these changes.'); | ||||
} else { | } else { | ||||
$warnings[] = pht('These changes have unit test problems.'); | $warnings[] = pht('These changes have unit test problems.'); | ||||
} | } | ||||
return $warnings; | return $warnings; | ||||
} | } | ||||
public function renderDiffPropertyViewValue(DifferentialDiff $diff) { | public function renderDiffPropertyViewValue(DifferentialDiff $diff) { | ||||
$buildable = $diff->getBuildable(); | |||||
$colors = array( | $colors = array( | ||||
DifferentialUnitStatus::UNIT_NONE => 'grey', | DifferentialUnitStatus::UNIT_NONE => 'grey', | ||||
DifferentialUnitStatus::UNIT_OKAY => 'green', | DifferentialUnitStatus::UNIT_OKAY => 'green', | ||||
DifferentialUnitStatus::UNIT_WARN => 'yellow', | DifferentialUnitStatus::UNIT_WARN => 'yellow', | ||||
DifferentialUnitStatus::UNIT_FAIL => 'red', | DifferentialUnitStatus::UNIT_FAIL => 'red', | ||||
DifferentialUnitStatus::UNIT_SKIP => 'blue', | DifferentialUnitStatus::UNIT_SKIP => 'blue', | ||||
DifferentialUnitStatus::UNIT_AUTO_SKIP => 'blue', | DifferentialUnitStatus::UNIT_AUTO_SKIP => 'blue', | ||||
); | ); | ||||
$icon_color = idx($colors, $diff->getUnitStatus(), 'grey'); | $view = id(new PHUIStatusListView()); | ||||
$message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff); | $builds_unit_status = null; | ||||
if ($buildable) { | |||||
$builds_unit_status = $buildable->getDetail( | |||||
HarbormasterBuildable::DETAIL_UNIT_STATUS); | |||||
$builds_unit_status = HarbormasterUnitStatus::getDifferentialUnitStatus( | |||||
$builds_unit_status); | |||||
} | |||||
if ($builds_unit_status) { | |||||
$icon_color = idx($colors, $builds_unit_status, 'grey'); | |||||
$message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage( | |||||
$builds_unit_status); | |||||
$unit_count = $buildable->getDetail( | |||||
HarbormasterBuildable::DETAIL_UNIT_COUNTS); | |||||
$counts = array(); | |||||
foreach ($unit_count as $status => $count) { | |||||
$counts[] = HarbormasterUnitStatus::getUnitStatusCountLabel( | |||||
$status, | |||||
$count); | |||||
} | |||||
$counts = implode(" \xC2\xB7 ", $counts); | |||||
$status = id(new PHUIStatusListView()) | $view->addItem( | ||||
->addItem( | |||||
id(new PHUIStatusItemView()) | id(new PHUIStatusItemView()) | ||||
->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color) | ->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color) | ||||
->setTarget($message)); | ->setTarget($message) | ||||
->setNote($counts)); | |||||
} | |||||
return $status; | $arcanist_tests_status = $diff->getUnitStatus(); | ||||
if ($arcanist_tests_status == DifferentialUnitStatus::UNIT_SKIP) { | |||||
$show_manual = true; | |||||
} else { | |||||
$show_manual = !$builds_unit_status; | |||||
} | } | ||||
if ($show_manual) { | |||||
$icon_color = idx($colors, $arcanist_tests_status, 'grey'); | |||||
$message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage( | |||||
$arcanist_tests_status); | |||||
$excuse = null; | |||||
if ($diff->hasDiffProperty('arc:unit-excuse')) { | |||||
$excuse = array( | |||||
phutil_tag('strong', array(), pht('Excuse:')), | |||||
' ', | |||||
phutil_escape_html_newlines($diff->getProperty('arc:unit-excuse')), | |||||
); | |||||
} | |||||
$view->addItem( | |||||
id(new PHUIStatusItemView()) | |||||
->setIcon(PHUIStatusItemView::ICON_STAR, $icon_color) | |||||
->setTarget($message) | |||||
->setNote($excuse)); | |||||
} | |||||
return $view; | |||||
} | |||||
} | } |