[autotest] Split GenerateBuildbotLinks()
BUG=chromium:672348
TEST=None
Change-Id: I55821cd1d7077edc2487f5d9e23c1a458f8437ca
Reviewed-on: https://chromium-review.googlesource.com/566075
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/site_utils/run_suite.py b/site_utils/run_suite.py
index 63487cc..1f6c24f 100755
--- a/site_utils/run_suite.py
+++ b/site_utils/run_suite.py
@@ -493,34 +493,45 @@
"""Generate a link formatted to meet buildbot expectations.
If there is a bug associated with this link, report a link to the bug
- and a link to the job logs;
- otherwise report a link to the job logs.
+ and a link to the job logs; otherwise report a link to the job logs.
- @return A list of links formatted for the buildbot log annotator.
+ @return A generator of links formatted for the buildbot log annotator.
"""
- bug_info_strings = []
- info_strings = []
+ if self.bug_url:
+ yield self._get_link_to_bug()
+ yield self._get_link_to_job_logs()
+
+ def _get_link_to_bug(self):
+ """Return buildbot link to bug.
+
+ @return A link formatted for the buildbot log annotator.
+ """
+ info_strings = self._get_info_strings()
+ info_strings.append(self._bug_count_text)
+ anchor_text = self._format_anchor_text(self._BUG_LINK_PREFIX,
+ info_strings)
+ return annotations.StepLink(anchor_text, self.bug_url)
+
+
+ def _get_link_to_job_logs(self):
+ """Return buildbot link to job logs.
+
+ @return A link formatted for the buildbot log annotator.
+ """
+ anchor_text = self._format_anchor_text(self._LOG_LINK_PREFIX,
+ self._get_info_strings())
+ return annotations.StepLink(anchor_text, self.url)
+
+
+ def _get_info_strings(self):
+ """Return a list of info strings for _format_anchor_text()."""
+ info_strings = []
if self.retry_count > 0:
info_strings.append('retry_count: %d' % self.retry_count)
- bug_info_strings.append('retry_count: %d' % self.retry_count)
-
if self.reason:
- bug_info_strings.append(self.reason)
info_strings.append(self.reason)
-
- # Add the bug link to buildbot_links
- if self.bug_url:
- bug_info_strings.append(self._bug_count_text)
-
- bug_anchor_text = self._format_anchor_text(self._BUG_LINK_PREFIX,
- bug_info_strings)
-
- yield annotations.StepLink(bug_anchor_text, self.bug_url)
-
- anchor_text = self._format_anchor_text(self._LOG_LINK_PREFIX,
- info_strings)
- yield annotations.StepLink(anchor_text, self.url)
+ return info_strings
def _format_anchor_text(self, prefix, info_strings):