mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +01:00
Allow unit test results to specify that their details are formatted with remarkup when reporting to "harbormaster.sendmessage"
Summary: Ref T13189. See PHI710. Ref T13088. Fixes T9951. Allow callers to `harbormaster.sendmessage` to specify that the test details are remarkup so they can use rich formatting and include links, files, etc. Test Plan: {F5840098} Reviewers: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13189, T13088, T9951 Differential Revision: https://secure.phabricator.com/D19615
This commit is contained in:
parent
632cafec88
commit
614f9ba1fb
9 changed files with 93 additions and 53 deletions
|
@ -75,7 +75,7 @@ return array(
|
||||||
'rsrc/css/application/feed/feed.css' => 'ecd4ec57',
|
'rsrc/css/application/feed/feed.css' => 'ecd4ec57',
|
||||||
'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948',
|
'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948',
|
||||||
'rsrc/css/application/flag/flag.css' => 'bba8f811',
|
'rsrc/css/application/flag/flag.css' => 'bba8f811',
|
||||||
'rsrc/css/application/harbormaster/harbormaster.css' => '730a4a3c',
|
'rsrc/css/application/harbormaster/harbormaster.css' => '7446ce72',
|
||||||
'rsrc/css/application/herald/herald-test.css' => 'a52e323e',
|
'rsrc/css/application/herald/herald-test.css' => 'a52e323e',
|
||||||
'rsrc/css/application/herald/herald.css' => 'cd8d0134',
|
'rsrc/css/application/herald/herald.css' => 'cd8d0134',
|
||||||
'rsrc/css/application/maniphest/report.css' => '9b9580b7',
|
'rsrc/css/application/maniphest/report.css' => '9b9580b7',
|
||||||
|
@ -554,7 +554,7 @@ return array(
|
||||||
'font-fontawesome' => 'e838e088',
|
'font-fontawesome' => 'e838e088',
|
||||||
'font-lato' => 'c7ccd872',
|
'font-lato' => 'c7ccd872',
|
||||||
'global-drag-and-drop-css' => 'b556a948',
|
'global-drag-and-drop-css' => 'b556a948',
|
||||||
'harbormaster-css' => '730a4a3c',
|
'harbormaster-css' => '7446ce72',
|
||||||
'herald-css' => 'cd8d0134',
|
'herald-css' => 'cd8d0134',
|
||||||
'herald-rule-editor' => 'dca75c0e',
|
'herald-rule-editor' => 'dca75c0e',
|
||||||
'herald-test-css' => 'a52e323e',
|
'herald-test-css' => 'a52e323e',
|
||||||
|
|
|
@ -1315,7 +1315,7 @@ final class DifferentialRevisionViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
return id(new HarbormasterUnitSummaryView())
|
return id(new HarbormasterUnitSummaryView())
|
||||||
->setUser($viewer)
|
->setViewer($viewer)
|
||||||
->setExcuse($excuse)
|
->setExcuse($excuse)
|
||||||
->setBuildable($diff->getBuildable())
|
->setBuildable($diff->getBuildable())
|
||||||
->setUnitMessages($diff->getUnitMessages())
|
->setUnitMessages($diff->getUnitMessages())
|
||||||
|
|
|
@ -318,7 +318,7 @@ final class HarbormasterBuildableViewController
|
||||||
|
|
||||||
if ($lint_data) {
|
if ($lint_data) {
|
||||||
$lint_table = id(new HarbormasterLintPropertyView())
|
$lint_table = id(new HarbormasterLintPropertyView())
|
||||||
->setUser($viewer)
|
->setViewer($viewer)
|
||||||
->setLimit(10)
|
->setLimit(10)
|
||||||
->setLintMessages($lint_data);
|
->setLintMessages($lint_data);
|
||||||
|
|
||||||
|
@ -343,6 +343,7 @@ final class HarbormasterBuildableViewController
|
||||||
|
|
||||||
if ($unit_data) {
|
if ($unit_data) {
|
||||||
$unit = id(new HarbormasterUnitSummaryView())
|
$unit = id(new HarbormasterUnitSummaryView())
|
||||||
|
->setViewer($viewer)
|
||||||
->setBuildable($buildable)
|
->setBuildable($buildable)
|
||||||
->setUnitMessages($unit_data)
|
->setUnitMessages($unit_data)
|
||||||
->setShowViewAll(true)
|
->setShowViewAll(true)
|
||||||
|
|
|
@ -39,6 +39,7 @@ final class HarbormasterUnitMessageListController
|
||||||
}
|
}
|
||||||
|
|
||||||
$unit = id(new HarbormasterUnitSummaryView())
|
$unit = id(new HarbormasterUnitSummaryView())
|
||||||
|
->setViewer($viewer)
|
||||||
->setBuildable($buildable)
|
->setBuildable($buildable)
|
||||||
->setUnitMessages($unit_data);
|
->setUnitMessages($unit_data);
|
||||||
|
|
||||||
|
|
|
@ -88,23 +88,7 @@ final class HarbormasterUnitMessageViewController
|
||||||
pht('Run At'),
|
pht('Run At'),
|
||||||
phabricator_datetime($message->getDateCreated(), $viewer));
|
phabricator_datetime($message->getDateCreated(), $viewer));
|
||||||
|
|
||||||
$details = $message->getUnitMessageDetails();
|
$details = $message->newUnitMessageDetailsView($viewer);
|
||||||
if (strlen($details)) {
|
|
||||||
// TODO: Use the log view here, once it gets cleaned up.
|
|
||||||
// Shenanigans below.
|
|
||||||
$details = phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'PhabricatorMonospaced',
|
|
||||||
'style' =>
|
|
||||||
'white-space: pre-wrap; '.
|
|
||||||
'color: #666666; '.
|
|
||||||
'overflow-x: auto;',
|
|
||||||
),
|
|
||||||
$details);
|
|
||||||
} else {
|
|
||||||
$details = phutil_tag('em', array(), pht('No details provided.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$view->addSectionHeader(
|
$view->addSectionHeader(
|
||||||
pht('Details'),
|
pht('Details'),
|
||||||
|
|
|
@ -13,6 +13,9 @@ final class HarbormasterBuildUnitMessage
|
||||||
|
|
||||||
private $buildTarget = self::ATTACHABLE;
|
private $buildTarget = self::ATTACHABLE;
|
||||||
|
|
||||||
|
const FORMAT_TEXT = 'text';
|
||||||
|
const FORMAT_REMARKUP = 'remarkup';
|
||||||
|
|
||||||
public static function initializeNewUnitMessage(
|
public static function initializeNewUnitMessage(
|
||||||
HarbormasterBuildTarget $build_target) {
|
HarbormasterBuildTarget $build_target) {
|
||||||
return id(new HarbormasterBuildUnitMessage())
|
return id(new HarbormasterBuildUnitMessage())
|
||||||
|
@ -66,6 +69,13 @@ final class HarbormasterBuildUnitMessage
|
||||||
'description' => pht(
|
'description' => pht(
|
||||||
'Additional human-readable information about the failure.'),
|
'Additional human-readable information about the failure.'),
|
||||||
),
|
),
|
||||||
|
'format' => array(
|
||||||
|
'type' => 'optional string',
|
||||||
|
'description' => pht(
|
||||||
|
'Format for the text provided in "details". Valid values are '.
|
||||||
|
'"text" (default) or "remarkup". This controls how test details '.
|
||||||
|
'are rendered when shown to users.'),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +114,11 @@ final class HarbormasterBuildUnitMessage
|
||||||
$obj->setProperty('details', $details);
|
$obj->setProperty('details', $details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$format = idx($dict, 'format');
|
||||||
|
if ($format) {
|
||||||
|
$obj->setProperty('format', $format);
|
||||||
|
}
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +164,66 @@ final class HarbormasterBuildUnitMessage
|
||||||
return $this->getProperty('details', '');
|
return $this->getProperty('details', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUnitMessageDetailsFormat() {
|
||||||
|
return $this->getProperty('format', self::FORMAT_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function newUnitMessageDetailsView(
|
||||||
|
PhabricatorUser $viewer,
|
||||||
|
$summarize = false) {
|
||||||
|
|
||||||
|
$format = $this->getUnitMessageDetailsFormat();
|
||||||
|
|
||||||
|
$is_text = ($format !== self::FORMAT_REMARKUP);
|
||||||
|
$is_remarkup = ($format === self::FORMAT_REMARKUP);
|
||||||
|
|
||||||
|
$full_details = $this->getUnitMessageDetails();
|
||||||
|
|
||||||
|
if (!strlen($full_details)) {
|
||||||
|
if ($summarize) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$details = phutil_tag('em', array(), pht('No details provided.'));
|
||||||
|
} else if ($summarize) {
|
||||||
|
if ($is_text) {
|
||||||
|
$details = id(new PhutilUTF8StringTruncator())
|
||||||
|
->setMaximumBytes(2048)
|
||||||
|
->truncateString($full_details);
|
||||||
|
$details = phutil_split_lines($details);
|
||||||
|
|
||||||
|
$limit = 3;
|
||||||
|
if (count($details) > $limit) {
|
||||||
|
$details = array_slice($details, 0, $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
$details = implode('', $details);
|
||||||
|
} else {
|
||||||
|
$details = $full_details;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$details = $full_details;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_celerity_resource('harbormaster-css');
|
||||||
|
|
||||||
|
$classes = array();
|
||||||
|
$classes[] = 'harbormaster-unit-details';
|
||||||
|
|
||||||
|
if ($is_remarkup) {
|
||||||
|
$details = new PHUIRemarkupView($viewer, $details);
|
||||||
|
} else {
|
||||||
|
$classes[] = 'harbormaster-unit-details-text';
|
||||||
|
$classes[] = 'PhabricatorMonospaced';
|
||||||
|
}
|
||||||
|
|
||||||
|
return phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => implode(' ', $classes),
|
||||||
|
),
|
||||||
|
$details);
|
||||||
|
}
|
||||||
|
|
||||||
public function getUnitMessageDisplayName() {
|
public function getUnitMessageDisplayName() {
|
||||||
$name = $this->getName();
|
$name = $this->getName();
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,8 @@ final class HarbormasterUnitPropertyView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
require_celerity_resource('harbormaster-css');
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$messages = $this->unitMessages;
|
$messages = $this->unitMessages;
|
||||||
$messages = msort($messages, 'getSortKey');
|
$messages = msort($messages, 'getSortKey');
|
||||||
|
@ -84,13 +83,10 @@ final class HarbormasterUnitPropertyView extends AphrontView {
|
||||||
$name);
|
$name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$details = $message->getUnitMessageDetails();
|
|
||||||
if (strlen($details)) {
|
|
||||||
$name = array(
|
$name = array(
|
||||||
$name,
|
$name,
|
||||||
$this->renderUnitTestDetails($details),
|
$message->newUnitMessageDetailsView($viewer, true),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
$result_icon,
|
$result_icon,
|
||||||
|
@ -158,25 +154,4 @@ final class HarbormasterUnitPropertyView extends AphrontView {
|
||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderUnitTestDetails($full_details) {
|
|
||||||
$details = id(new PhutilUTF8StringTruncator())
|
|
||||||
->setMaximumBytes(2048)
|
|
||||||
->truncateString($full_details);
|
|
||||||
$details = phutil_split_lines($details);
|
|
||||||
|
|
||||||
$limit = 3;
|
|
||||||
if (count($details) > $limit) {
|
|
||||||
$details = array_slice($details, 0, $limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
$details = implode('', $details);
|
|
||||||
|
|
||||||
return phutil_tag(
|
|
||||||
'div',
|
|
||||||
array(
|
|
||||||
'class' => 'PhabricatorMonospaced harbormaster-unit-details',
|
|
||||||
),
|
|
||||||
$details);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ final class HarbormasterUnitSummaryView extends AphrontView {
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
|
||||||
|
|
||||||
$table = id(new HarbormasterUnitPropertyView())
|
$table = id(new HarbormasterUnitPropertyView())
|
||||||
|
->setViewer($this->getViewer())
|
||||||
->setUnitMessages($messages);
|
->setUnitMessages($messages);
|
||||||
|
|
||||||
if ($this->showViewAll) {
|
if ($this->showViewAll) {
|
||||||
|
|
|
@ -26,11 +26,14 @@
|
||||||
.harbormaster-unit-details {
|
.harbormaster-unit-details {
|
||||||
margin: 8px 0 4px;
|
margin: 8px 0 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: pre;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
color: {$lightgreytext};
|
color: {$lightgreytext};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.harbormaster-unit-details-text {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.harbormaster-log-view-loading {
|
.harbormaster-log-view-loading {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
Loading…
Reference in a new issue