Changeset 85871 in webkit


Ignore:
Timestamp:
May 5, 2011 1:18:40 PM (13 years ago)
Author:
eric@webkit.org
Message:

2011-05-05 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

commit-queue should reject patches which fail ewses
https://bugs.webkit.org/show_bug.cgi?id=47534

  • Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
  • Scripts/webkitpy/tool/commands/earlywarningsystem.py:
  • Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r85867 r85871  
     12011-05-05  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        commit-queue should reject patches which fail ewses
     6        https://bugs.webkit.org/show_bug.cgi?id=47534
     7
     8        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
     9        * Scripts/webkitpy/tool/commands/earlywarningsystem.py:
     10        * Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
     11
    1122011-05-05  Chang Shu  <cshu@webkit.org>
    213
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py

    r85727 r85871  
    617617        self.authenticate()
    618618
     619        # FIXME: additional_comment_text seems useless and should be merged into comment-text.
    619620        if additional_comment_text:
    620621            comment_text += "\n\n%s" % additional_comment_text
     
    660661        self.authenticate()
    661662
    662         log("Adding %s to the CC list for bug %s" % (email_address_list,
    663                                                      bug_id))
     663        log("Adding %s to the CC list for bug %s" % (email_address_list, bug_id))
    664664        if self.dryrun:
    665665            return
  • trunk/Tools/Scripts/webkitpy/tool/commands/earlywarningsystem.py

    r85821 r85871  
    100100
    101101    @classmethod
     102    def _post_reject_message_on_bug(cls, tool, patch, status_id, extra_message_text=None):
     103        results_link = tool.status_server.results_url_for_status(status_id)
     104        message = "Attachment %s did not pass %s (%s):\nOutput: %s" % (patch.id(), cls.name, cls.port_name, results_link)
     105        # FIXME: We might want to add some text about rejecting from the commit-queue in
     106        # the case where patch.commit_queue() isn't already set to '-'.
     107        if cls.watchers:
     108            tool.bugs.add_cc_to_bug(patch.bug_id(), cls.watchers)
     109        tool.bugs.set_flag_on_attachment(patch.bug_id(), "commit-queue", "-", message, extra_message_text)
     110
     111    @classmethod
    102112    def handle_script_error(cls, tool, state, script_error):
    103113        is_svn_apply = script_error.command_name() == "svn-apply"
     
    105115        if is_svn_apply:
    106116            QueueEngine.exit_after_handled_error(script_error)
    107         results_link = tool.status_server.results_url_for_status(status_id)
    108         message = "Attachment %s did not build on %s:\nBuild output: %s" % (state["patch"].id(), cls.port_name, results_link)
    109         tool.bugs.post_comment_to_bug(state["patch"].bug_id(), message, cc=cls.watchers)
     117        cls._post_reject_message_on_bug(tool, state['patch'], status_id)
    110118        exit(1)
     119
    111120
    112121# FIXME: This should merge with AbstractEarlyWarningSystem once all the EWS
     
    120129        self._layout_test_results_reader = LayoutTestResultsReader(self._tool, self._log_directory())
    121130
    122     def _post_reject_message_on_bug(self, task, patch):
    123         results_link = self._tool.status_server.results_url_for_status(task.failure_status_id)
    124         message = "Attachment %s did not pass %s:\nOutput: %s" % (patch.id(), self.name, results_link)
     131    def _failing_tests_message(self, task, patch):
    125132        results = task.results_from_patch_test_run(patch)
    126133        unexpected_failures = self._expected_failures.unexpected_failures(results)
    127         if unexpected_failures:
    128             message += "\nNew failing tests:\n%s" % "\n".join(unexpected_failures)
    129         self._tool.bugs.post_comment_to_bug(patch.bug_id(), message, cc=self.watchers)
     134        if not unexpected_failures:
     135            return None
     136        return "New failing tests:\n%s" % "\n".join(unexpected_failures)
    130137
    131138    def review_patch(self, patch):
     
    140147            return False
    141148        except ScriptError, e:
    142             # FIXME: This should just use CommitterValidator.reject_patch_from_commit_queue
    143             self._post_reject_message_on_bug(task, patch)
     149            self._post_reject_message_on_bug(self._tool, patch, task.failure_status_id, self._failing_tests_message(task, patch))
    144150            results_archive = task.results_archive_from_patch_test_run(patch)
    145151            if results_archive:
  • trunk/Tools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py

    r85802 r85871  
    3838
    3939class AbstractEarlyWarningSystemTest(QueuesTest):
     40    # Needed to define port_name, used in AbstractEarlyWarningSystem.__init__
     41    class TestEWS(AbstractEarlyWarningSystem):
     42        name = "mock-ews"
     43        port_name = "win"  # Needs to be a port which port/factory understands.
     44
    4045    def test_can_build(self):
    41         # Needed to define port_name, used in AbstractEarlyWarningSystem.__init__
    42         class TestEWS(AbstractEarlyWarningSystem):
    43             port_name = "win"  # Needs to be a port which port/factory understands.
    44 
    45         queue = TestEWS()
     46        queue = self.TestEWS()
    4647        queue.bind_to_tool(MockTool(log_executive=True))
    4748        queue._options = MockOptions(port=None)
     
    5354
    5455        queue.run_webkit_patch = mock_run_webkit_patch
    55         expected_stderr = "MOCK: update_status: None Unable to perform a build\n"
     56        expected_stderr = "MOCK: update_status: mock-ews Unable to perform a build\n"
    5657        OutputCapture().assert_outputs(self, queue._can_build, [], expected_stderr=expected_stderr)
    5758
     
    6869        expected_stderr = "MOCK: release_work_item: None 197\n"
    6970        OutputCapture().assert_outputs(self, queue.process_work_item, [mock_patch], expected_stderr=expected_stderr, expected_exception=ScriptError)
     71
     72    def test_post_reject_message_on_bug(self):
     73        tool = MockTool()
     74        patch = tool.bugs.fetch_attachment(197)
     75        expected_stderr = """MOCK setting flag 'commit-queue' to '-' on attachment '42' with comment 'Attachment 197 did not pass mock-ews (win):
     76Output: http://dummy_url' and additional comment 'EXTRA'
     77"""
     78        OutputCapture().assert_outputs(self,
     79            self.TestEWS._post_reject_message_on_bug,
     80            kwargs={'tool': tool, 'patch': patch, 'status_id': 1, 'extra_message_text': "EXTRA"},
     81            expected_stderr=expected_stderr)
     82
     83
     84class AbstractTestingEWSTest(QueuesTest):
     85    def test_failing_tests_message(self):
     86        # Needed to define port_name, used in AbstractEarlyWarningSystem.__init__
     87        class TestEWS(AbstractTestingEWS):
     88            port_name = "win"  # Needs to be a port which port/factory understands.
     89
     90        ews = TestEWS()
     91        ews.bind_to_tool(MockTool())
     92        ews._options = MockOptions(port=None, confirm=False)
     93        OutputCapture().assert_outputs(self, ews.begin_work_queue, expected_stderr=self._default_begin_work_queue_stderr(ews.name, ews._tool.scm().checkout_root))
     94        ews._expected_failures.unexpected_failures = lambda results: set(["foo.html", "bar.html"])
     95        task = Mock()
     96        patch = ews._tool.bugs.fetch_attachment(197)
     97        self.assertEqual(ews._failing_tests_message(task, patch), "New failing tests:\nbar.html\nfoo.html")
    7098
    7199
     
    90118            "next_work_item": "",
    91119            "process_work_item": "MOCK: update_status: %(name)s Pass\nMOCK: release_work_item: %(name)s 197\n" % string_replacemnts,
    92             "handle_script_error": "MOCK: update_status: %(name)s ScriptError error message\nMOCK bug comment: bug_id=42, cc=%(watchers)s\n--- Begin comment ---\nAttachment 197 did not build on %(port)s:\nBuild output: http://dummy_url\n--- End comment ---\n\n" % string_replacemnts,
     120            "handle_script_error": """MOCK: update_status: %(name)s ScriptError error message
     121MOCK setting flag 'commit-queue' to '-' on attachment '42' with comment 'Attachment 197 did not pass %(name)s (%(port)s):
     122Output: http://dummy_url' and additional comment 'None'
     123""" % string_replacemnts,
    93124        }
    94125        return expected_stderr
Note: See TracChangeset for help on using the changeset viewer.