Title: [258760] trunk/Tools
Revision
258760
Author
aakash_j...@apple.com
Date
2020-03-20 07:31:36 -0700 (Fri, 20 Mar 2020)

Log Message

[ews] commit-queue should comment on bug if patch fails to apply
https://bugs.webkit.org/show_bug.cgi?id=209334

Reviewed by Jonathan Bedard.

* BuildSlaveSupport/ews-build/steps.py:
(ApplyPatch):
(ApplyPatch.evaluateCommand): Overridden to check build status and queue name and comment on bug accordingly.
* BuildSlaveSupport/ews-build/steps_unittest.py: Added unit-tests.
(TestApplyPatch):
(TestApplyPatch.setUp):
(TestApplyPatch.setUp.mock_start):
(TestApplyPatch.tearDown):
(TestApplyPatch.test_success):
(TestApplyPatch.test_failure):
(TestApplyPatch.test_failure_on_commit_queue):

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/ews-build/steps.py (258759 => 258760)


--- trunk/Tools/BuildSlaveSupport/ews-build/steps.py	2020-03-20 11:48:08 UTC (rev 258759)
+++ trunk/Tools/BuildSlaveSupport/ews-build/steps.py	2020-03-20 14:31:36 UTC (rev 258760)
@@ -192,8 +192,7 @@
     name = 'apply-patch'
     description = ['applying-patch']
     descriptionDone = ['Applied patch']
-    flunkOnFailure = True
-    haltOnFailure = True
+    haltOnFailure = False
     command = ['perl', 'Tools/Scripts/svn-apply', '--force', '.buildbot-diff']
 
     def __init__(self, **kwargs):
@@ -225,7 +224,20 @@
             return {u'step': u'Patch does not apply'}
         return super(ApplyPatch, self).getResultSummary()
 
+    def evaluateCommand(self, cmd):
+        rc = shell.ShellCommand.evaluateCommand(self, cmd)
+        patch_id = self.getProperty('patch_id', '')
+        if rc == FAILURE:
+            message = 'Patch {} does not apply'.format(patch_id)
+            if self.getProperty('buildername', '').lower() == 'commit-queue':
+                self.setProperty('bugzilla_comment_text', message.replace('Patch', 'Attachment'))
+                self.setProperty('build_finish_summary', message)
+                self.build.addStepsAfterCurrentStep([CommentOnBug(), SetCommitQueueMinusFlagOnPatch()])
+            else:
+                self.build.buildFinished([message], FAILURE)
+        return rc
 
+
 class CheckPatchRelevance(buildstep.BuildStep):
     name = 'check-patch-relevance'
     description = ['check-patch-relevance running']

Modified: trunk/Tools/BuildSlaveSupport/ews-build/steps_unittest.py (258759 => 258760)


--- trunk/Tools/BuildSlaveSupport/ews-build/steps_unittest.py	2020-03-20 11:48:08 UTC (rev 258759)
+++ trunk/Tools/BuildSlaveSupport/ews-build/steps_unittest.py	2020-03-20 14:31:36 UTC (rev 258760)
@@ -2032,6 +2032,71 @@
         return self.runStep()
 
 
+class TestApplyPatch(BuildStepMixinAdditions, unittest.TestCase):
+    def setUp(self):
+        self.longMessage = True
+
+        def mock_start(cls, *args, **kwargs):
+            from buildbot.steps import shell
+            return shell.ShellCommand.start(cls)
+        ApplyPatch.start = mock_start
+        return self.setUpBuildStep()
+
+    def tearDown(self):
+        return self.tearDownBuildStep()
+
+    def test_success(self):
+        self.setupStep(ApplyPatch())
+        self.assertEqual(ApplyPatch.flunkOnFailure, True)
+        self.assertEqual(ApplyPatch.haltOnFailure, False)
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=600,
+                        logEnviron=False,
+                        command=['perl', 'Tools/Scripts/svn-apply', '--force', '.buildbot-diff'],
+                        ) +
+            0,
+        )
+        self.expectOutcome(result=SUCCESS, state_string='Applied patch')
+        return self.runStep()
+
+    def test_failure(self):
+        self.setupStep(ApplyPatch())
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=600,
+                        logEnviron=False,
+                        command=['perl', 'Tools/Scripts/svn-apply', '--force', '.buildbot-diff'],
+                        ) +
+            ExpectShell.log('stdio', stdout='Unexpected failure.') +
+            2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Patch does not apply')
+        rc = self.runStep()
+        self.assertEqual(self.getProperty('bugzilla_comment_text'), None)
+        self.assertEqual(self.getProperty('build_finish_summary'), None)
+        return rc
+
+    def test_failure_on_commit_queue(self):
+        self.setupStep(ApplyPatch())
+        self.setProperty('buildername', 'Commit-Queue')
+        self.setProperty('patch_id', '1234')
+        self.expectRemoteCommands(
+            ExpectShell(workdir='wkdir',
+                        timeout=600,
+                        logEnviron=False,
+                        command=['perl', 'Tools/Scripts/svn-apply', '--force', '.buildbot-diff'],
+                        ) +
+            ExpectShell.log('stdio', stdout='Unexpected failure.') +
+            2,
+        )
+        self.expectOutcome(result=FAILURE, state_string='Patch does not apply')
+        rc = self.runStep()
+        self.assertEqual(self.getProperty('bugzilla_comment_text'), 'Attachment 1234 does not apply')
+        self.assertEqual(self.getProperty('build_finish_summary'), 'Patch 1234 does not apply')
+        return rc
+
+
 class TestUnApplyPatchIfRequired(BuildStepMixinAdditions, unittest.TestCase):
     def setUp(self):
         self.longMessage = True

Modified: trunk/Tools/ChangeLog (258759 => 258760)


--- trunk/Tools/ChangeLog	2020-03-20 11:48:08 UTC (rev 258759)
+++ trunk/Tools/ChangeLog	2020-03-20 14:31:36 UTC (rev 258760)
@@ -1,5 +1,24 @@
 2020-03-20  Aakash Jain  <aakash_j...@apple.com>
 
+        [ews] commit-queue should comment on bug if patch fails to apply
+        https://bugs.webkit.org/show_bug.cgi?id=209334
+
+        Reviewed by Jonathan Bedard.
+
+        * BuildSlaveSupport/ews-build/steps.py:
+        (ApplyPatch):
+        (ApplyPatch.evaluateCommand): Overridden to check build status and queue name and comment on bug accordingly.
+        * BuildSlaveSupport/ews-build/steps_unittest.py: Added unit-tests.
+        (TestApplyPatch):
+        (TestApplyPatch.setUp):
+        (TestApplyPatch.setUp.mock_start):
+        (TestApplyPatch.tearDown):
+        (TestApplyPatch.test_success):
+        (TestApplyPatch.test_failure):
+        (TestApplyPatch.test_failure_on_commit_queue):
+
+2020-03-20  Aakash Jain  <aakash_j...@apple.com>
+
         [EWS] Limit number of builds to display in status-bubble hover over message in case of lot of retried builds
         https://bugs.webkit.org/show_bug.cgi?id=209122
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to