@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show broken units in revision history

Summary:
This is hacky, and I'm not sure I'm happy with it; Until T9365 is done, this will show up
broken tests with an appropriate star in the Revision History.

Test Plan: Created 1M messages in a couple of old diffs in a revision. The query took ~80us (On SSD drive).

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D16483

+62 -9
+42
src/applications/differential/controller/DifferentialRevisionViewController.php
··· 292 292 '/differential/comment/inline/edit/'.$revision->getID().'/'); 293 293 } 294 294 295 + $broken_diffs = $this->loadHistoryDiffStatus($diffs); 296 + 295 297 $history = id(new DifferentialRevisionUpdateHistoryView()) 296 298 ->setUser($viewer) 297 299 ->setDiffs($diffs) 300 + ->setDiffUnitStatuses($broken_diffs) 298 301 ->setSelectedVersusDiffID($diff_vs) 299 302 ->setSelectedDiffID($target->getID()) 300 303 ->setSelectedWhitespace($whitespace) ··· 774 777 } 775 778 776 779 return $actions_dict; 780 + } 781 + 782 + private function loadHistoryDiffStatus(array $diffs) { 783 + assert_instances_of($diffs, 'DifferentialDiff'); 784 + 785 + $diff_phids = mpull($diffs, 'getPHID'); 786 + $bad_unit_status = array( 787 + ArcanistUnitTestResult::RESULT_FAIL, 788 + ArcanistUnitTestResult::RESULT_BROKEN, 789 + ); 790 + 791 + $message = new HarbormasterBuildUnitMessage(); 792 + $target = new HarbormasterBuildTarget(); 793 + $build = new HarbormasterBuild(); 794 + $buildable = new HarbormasterBuildable(); 795 + 796 + $broken_diffs = queryfx_all( 797 + $message->establishConnection('r'), 798 + 'SELECT distinct a.buildablePHID 799 + FROM %T m 800 + JOIN %T t ON m.buildTargetPHID = t.phid 801 + JOIN %T b ON t.buildPHID = b.phid 802 + JOIN %T a ON b.buildablePHID = a.phid 803 + WHERE a.buildablePHID IN (%Ls) 804 + AND m.result in (%Ls)', 805 + $message->getTableName(), 806 + $target->getTableName(), 807 + $build->getTableName(), 808 + $buildable->getTableName(), 809 + $diff_phids, 810 + $bad_unit_status); 811 + 812 + $unit_status = array(); 813 + foreach ($broken_diffs as $broken) { 814 + $phid = $broken['buildablePHID']; 815 + $unit_status[$phid] = DifferentialUnitStatus::UNIT_FAIL; 816 + } 817 + 818 + return $unit_status; 777 819 } 778 820 779 821 private function loadChangesetsAndVsMap(
+2 -1
src/applications/differential/customfield/DifferentialUnitField.php
··· 61 61 ); 62 62 $icon_color = idx($colors, $diff->getUnitStatus(), 'grey'); 63 63 64 - $message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff); 64 + $message = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage( 65 + $diff->getUnitStatus()); 65 66 66 67 $status = id(new PHUIStatusListView()) 67 68 ->addItem(
+18 -8
src/applications/differential/view/DifferentialRevisionUpdateHistoryView.php
··· 7 7 private $selectedDiffID; 8 8 private $selectedWhitespace; 9 9 private $commitsForLinks = array(); 10 + private $unitStatus = array(); 10 11 11 12 public function setDiffs(array $diffs) { 12 13 assert_instances_of($diffs, 'DifferentialDiff'); ··· 32 33 public function setCommitsForLinks(array $commits) { 33 34 assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 34 35 $this->commitsForLinks = $commits; 36 + return $this; 37 + } 38 + 39 + public function setDiffUnitStatuses(array $unit_status) { 40 + $this->unitStatus = $unit_status; 35 41 return $this; 36 42 } 37 43 ··· 139 145 } 140 146 141 147 if ($diff) { 148 + $unit_status = idx( 149 + $this->unitStatus, 150 + $diff->getPHID(), 151 + $diff->getUnitStatus()); 152 + 142 153 $lint = self::renderDiffLintStar($row['obj']); 143 154 $lint = phutil_tag( 144 155 'div', ··· 148 159 ), 149 160 $lint); 150 161 151 - $unit = self::renderDiffUnitStar($row['obj']); 162 + $unit = self::renderDiffUnitStar($unit_status); 152 163 $unit = phutil_tag( 153 164 'div', 154 165 array( 155 166 'class' => 'lintunit-star', 156 - 'title' => self::getDiffUnitMessage($diff), 167 + 'title' => self::getDiffUnitMessage($unit_status), 157 168 ), 158 169 $unit); 159 170 ··· 312 323 const STAR_FAIL = 'fail'; 313 324 const STAR_SKIP = 'skip'; 314 325 315 - public static function renderDiffLintStar(DifferentialDiff $diff) { 326 + private static function renderDiffLintStar(DifferentialDiff $diff) { 316 327 static $map = array( 317 328 DifferentialLintStatus::LINT_NONE => self::STAR_NONE, 318 329 DifferentialLintStatus::LINT_OKAY => self::STAR_OKAY, ··· 327 338 return self::renderDiffStar($star); 328 339 } 329 340 330 - public static function renderDiffUnitStar(DifferentialDiff $diff) { 341 + private static function renderDiffUnitStar($unit_status) { 331 342 static $map = array( 332 343 DifferentialUnitStatus::UNIT_NONE => self::STAR_NONE, 333 344 DifferentialUnitStatus::UNIT_OKAY => self::STAR_OKAY, ··· 336 347 DifferentialUnitStatus::UNIT_SKIP => self::STAR_SKIP, 337 348 DifferentialUnitStatus::UNIT_AUTO_SKIP => self::STAR_SKIP, 338 349 ); 339 - 340 - $star = idx($map, $diff->getUnitStatus(), self::STAR_FAIL); 350 + $star = idx($map, $unit_status, self::STAR_FAIL); 341 351 342 352 return self::renderDiffStar($star); 343 353 } ··· 360 370 return pht('Unknown'); 361 371 } 362 372 363 - public static function getDiffUnitMessage(DifferentialDiff $diff) { 364 - switch ($diff->getUnitStatus()) { 373 + public static function getDiffUnitMessage($unit_status) { 374 + switch ($unit_status) { 365 375 case DifferentialUnitStatus::UNIT_NONE: 366 376 return pht('No Unit Test Coverage'); 367 377 case DifferentialUnitStatus::UNIT_OKAY: