Commit 020b5972 authored by Edward Lemur's avatar Edward Lemur Committed by Commit Bot

presubmit: Remove EnsureCQIncludeTrybotsAreAdded

Bug: 845642
Change-Id: I552b2da4abbac7ca7f6f3961d2b1c5002fb26f47
Reviewed-on: https://chromium-review.googlesource.com/c/1351509Reviewed-by: 's avatarAndy Perelson <ajp@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 7ae5d7a9
......@@ -437,39 +437,6 @@ class OutputApi(object):
return self.PresubmitNotifyResult(*args, **kwargs)
return self.PresubmitPromptWarning(*args, **kwargs)
def EnsureCQIncludeTrybotsAreAdded(self, cl, bots_to_include, message):
"""Helper for any PostUploadHook wishing to add CQ_INCLUDE_TRYBOTS.
Merges the bots_to_include into the current CQ_INCLUDE_TRYBOTS list,
keeping it alphabetically sorted. Returns the results that should be
returned from the PostUploadHook.
Args:
cl: The git_cl.Changelist object.
bots_to_include: A list of strings of bots to include, in the form
"master:slave".
message: A message to be printed in the case that
CQ_INCLUDE_TRYBOTS was updated.
"""
description = cl.GetDescription(force=True)
trybot_footers = git_footers.parse_footers(description).get(
git_footers.normalize_name('Cq-Include-Trybots'), [])
prior_bots = []
for f in trybot_footers:
prior_bots += [b.strip() for b in f.split(';') if b.strip()]
if set(prior_bots) >= set(bots_to_include):
return []
all_bots = ';'.join(sorted(set(prior_bots) | set(bots_to_include)))
description = git_footers.remove_footer(description, 'Cq-Include-Trybots')
description = git_footers.add_footer(
description, 'Cq-Include-Trybots', all_bots,
before_keys=['Change-Id'])
cl.UpdateDescription(description, force=True)
return [self.PresubmitNotifyResult(message)]
class InputApi(object):
"""An instance of this object is passed to presubmit scripts so they can
......
......@@ -1392,7 +1392,6 @@ class OutputApiUnittest(PresubmitTestsBase):
'PresubmitResult',
'is_committing',
'more_cc',
'EnsureCQIncludeTrybotsAreAdded',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit.OutputApi(False), members)
......@@ -1462,119 +1461,6 @@ class OutputApiUnittest(PresubmitTestsBase):
self.failIf(output.should_continue())
self.failUnless(output.getvalue().count('???'))
def _testIncludingCQTrybots(self, cl_text, new_trybots, updated_cl_text):
class FakeCL(object):
def __init__(self, description):
self._description = description
def GetDescription(self, force=False):
return self._description
def UpdateDescription(self, description, force=False):
self._description = description
def FakePresubmitNotifyResult(message):
return message
cl = FakeCL(cl_text)
output_api = presubmit.OutputApi(False)
output_api.PresubmitNotifyResult = FakePresubmitNotifyResult
message = 'Automatically added optional bots to run on CQ.'
results = output_api.EnsureCQIncludeTrybotsAreAdded(
cl,
new_trybots,
message)
self.assertEqual(updated_cl_text, cl.GetDescription())
self.assertEqual([message], results)
def testEnsureCQIncludeTrybotsAreAdded(self):
# We need long lines in this test.
# pylint: disable=line-too-long
# Deliberately has a spaces to exercise space-stripping code.
self._testIncludingCQTrybots(
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel;luci.chromium.try:win_optional_gpu_tests_rel
""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
'luci.chromium.try:win_optional_gpu_tests_rel'
],
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel""")
# Starting without any CQ_INCLUDE_TRYBOTS line.
self._testIncludingCQTrybots(
"""A change to GPU-related code.""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
'luci.chromium.try:mac_optional_gpu_tests_rel',
],
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel""")
# All pre-existing bots are already in output set.
self._testIncludingCQTrybots(
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:win_optional_gpu_tests_rel
""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
'luci.chromium.try:win_optional_gpu_tests_rel'
],
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel""")
# Equivalent tests with a pre-existing Change-Id line.
self._testIncludingCQTrybots(
"""A change to GPU-related code.
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
'luci.chromium.try:mac_optional_gpu_tests_rel',
],
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""")
self._testIncludingCQTrybots(
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2
""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
'luci.chromium.try:win_optional_gpu_tests_rel',
],
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""")
self._testIncludingCQTrybots(
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_rel
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_dbg
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2
""",
[
'luci.chromium.try:linux_optional_gpu_tests_rel',
'luci.chromium.try:win_optional_gpu_tests_rel',
],
"""A change to GPU-related code.
Cq-Include-Trybots: luci.chromium.try:linux_optional_gpu_tests_dbg;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Idaeacea9cdbe912c24c8388147a8a767c7baa5f2""")
class AffectedFileUnittest(PresubmitTestsBase):
def testMembersChanged(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment