Changeset 60976 in webkit


Ignore:
Timestamp:
Jun 10, 2010 2:55:34 PM (14 years ago)
Author:
ojan@chromium.org
Message:

2010-06-10 Ojan Vafai <ojan@chromium.org>

Reviewed by Adam Barth.

fix handle_script_error in rietveld upload queue and add testing for handle_script_error
https://bugs.webkit.org/show_bug.cgi?id=40436

  • Scripts/webkitpy/common/system/outputcapture.py:
  • Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
  • Scripts/webkitpy/tool/commands/queues.py:
  • Scripts/webkitpy/tool/commands/queues_unittest.py:
  • Scripts/webkitpy/tool/commands/queuestest.py:
  • Scripts/webkitpy/tool/mocktool.py:
Location:
trunk/WebKitTools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r60971 r60976  
     12010-06-10  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        fix handle_script_error in rietveld upload queue and add testing for handle_script_error
     6        https://bugs.webkit.org/show_bug.cgi?id=40436
     7
     8        * Scripts/webkitpy/common/system/outputcapture.py:
     9        * Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py:
     10        * Scripts/webkitpy/tool/commands/queues.py:
     11        * Scripts/webkitpy/tool/commands/queues_unittest.py:
     12        * Scripts/webkitpy/tool/commands/queuestest.py:
     13        * Scripts/webkitpy/tool/mocktool.py:
     14
    1152010-06-10  Jarkko Sakkinen  <jarkko.j.sakkinen@gmail.com>
    216
  • trunk/WebKitTools/Scripts/webkitpy/common/system/outputcapture.py

    r56519 r60976  
    5353        return (self._restore_output_with_name("stdout"), self._restore_output_with_name("stderr"))
    5454
    55     def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_stdout="", expected_stderr=""):
     55    def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_stdout="", expected_stderr="", expected_exception=None):
    5656        self.capture_output()
    57         return_value = function(*args, **kwargs)
     57        if expected_exception:
     58            return_value = testcase.assertRaises(expected_exception, function, *args, **kwargs)
     59        else:
     60            return_value = function(*args, **kwargs)
    5861        (stdout_string, stderr_string) = self.restore_output()
    5962        testcase.assertEqual(stdout_string, expected_stdout)
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py

    r59978 r60976  
    4444            "name": ews.name,
    4545            "checkout_dir": os.getcwd(),  # FIXME: Use of os.getcwd() is wrong, should be scm.checkout_root
     46            "port": ews.port_name,
     47            "watchers": ews.watchers,
    4648        }
    4749        expected_stderr = {
     
    5052            "next_work_item": "MOCK: update_work_items: %(name)s [103]\n" % string_replacemnts,
    5153            "process_work_item": "MOCK: update_status: %(name)s Pass\n" % string_replacemnts,
     54            "handle_script_error": "MOCK: update_status: %(name)s ScriptError error message\nMOCK bug comment: bug_id=345, cc=%(watchers)s\n--- Begin comment ---\\Attachment 1234 did not build on %(port)s:\nBuild output: http://dummy_url\n--- End comment ---\n\n" % string_replacemnts,
    5255        }
    5356        return expected_stderr
    5457
    5558    def _test_ews(self, ews):
    56         self.assert_queue_outputs(ews, expected_stderr=self._default_expected_stderr(ews))
     59        expected_exceptions = {
     60            "handle_script_error": SystemExit,
     61        }
     62        self.assert_queue_outputs(ews, expected_stderr=self._default_expected_stderr(ews), expected_exceptions=expected_exceptions)
    5763
    5864    # FIXME: If all EWSes are going to output the same text, we
     
    7480        expected_stderr = self._default_expected_stderr(ews)
    7581        expected_stderr["process_work_item"] = "MOCK: update_status: mac-ews Error: mac-ews cannot process patches from non-committers :(\n"
    76         self.assert_queue_outputs(ews, expected_stderr=expected_stderr)
     82        expected_exceptions = {
     83            "handle_script_error": SystemExit,
     84        }
     85        self.assert_queue_outputs(ews, expected_stderr=expected_stderr, expected_exceptions=expected_exceptions)
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues.py

    r60924 r60976  
    332332            raise e
    333333
    334     def _reject_patch(self, patch_id, message):
    335         self.tool.bugs.set_flag_on_attachment(patch_id, "in-rietveld", "-")
     334    @classmethod
     335    def _reject_patch(cls, tool, patch_id):
     336        tool.bugs.set_flag_on_attachment(patch_id, "in-rietveld", "-")
    336337
    337338    def handle_unexpected_error(self, patch, message):
    338         self._reject_patch(patch.id(), message)
     339        log(message)
     340        self._reject_patch(self.tool, patch.id())
    339341
    340342    # StepSequenceErrorHandler methods
     
    342344    @classmethod
    343345    def handle_script_error(cls, tool, state, script_error):
    344         status_id = cls._update_status_for_script_error(tool, state, script_error)
    345         cls._reject_patch(state["patch"].id())
     346        log(script_error.message_with_output())
     347        cls._update_status_for_script_error(tool, state, script_error)
     348        cls._reject_patch(tool, state["patch"].id())
    346349
    347350
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py

    r60924 r60976  
    129129            "process_work_item" : "MOCK: update_status: commit-queue Pass\n",
    130130            "handle_unexpected_error" : "MOCK setting flag 'commit-queue' to '-' on attachment '1234' with comment 'Rejecting patch 1234 from commit-queue.' and additional comment 'Mock error message'\n",
     131            "handle_script_error": "MOCK: update_status: commit-queue ScriptError error message\nMOCK setting flag 'commit-queue' to '-' on attachment '1234' with comment 'Rejecting patch 1234 from commit-queue.' and additional comment 'ScriptError error message'\n",
    131132        }
    132133        self.assert_queue_outputs(CommitQueue(), expected_stderr=expected_stderr)
     
    148149            "process_work_item" : "MOCK: update_status: commit-queue Builders [\"Builder2\"] are red. See http://build.webkit.org\n",
    149150            "handle_unexpected_error" : "MOCK setting flag 'commit-queue' to '-' on attachment '1234' with comment 'Rejecting patch 1234 from commit-queue.' and additional comment 'Mock error message'\n",
     151            "handle_script_error": "MOCK: update_status: commit-queue ScriptError error message\nMOCK setting flag 'commit-queue' to '-' on attachment '1234' with comment 'Rejecting patch 1234 from commit-queue.' and additional comment 'ScriptError error message'\n",
    150152        }
    151153        self.assert_queue_outputs(CommitQueue(), tool=tool, expected_stderr=expected_stderr)
     
    168170            "process_work_item": "MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--build', '--non-interactive', '--ignore-builders', '--build-style=both', '--quiet', 76543]\nMOCK: update_status: commit-queue Pass\n",
    169171            "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '76543' with comment 'Rejecting patch 76543 from commit-queue.' and additional comment 'Mock error message'\n",
     172            "handle_script_error": "MOCK: update_status: commit-queue ScriptError error message\nMOCK setting flag 'commit-queue' to '-' on attachment '1234' with comment 'Rejecting patch 1234 from commit-queue.' and additional comment 'ScriptError error message'\n",
    170173        }
    171174        self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_stderr=expected_stderr)
     
    206209            "should_proceed_with_work_item": "MOCK: update_status: rietveld-upload-queue Uploading patch\n",
    207210            "process_work_item": "MOCK: update_status: rietveld-upload-queue Pass\n",
    208             "handle_unexpected_error": "MOCK setting flag 'in-rietveld' to '-' on attachment '1234' with comment 'None' and additional comment 'None'\n",
     211            "handle_unexpected_error": "Mock error message\nMOCK setting flag 'in-rietveld' to '-' on attachment '1234' with comment 'None' and additional comment 'None'\n",
     212            "handle_script_error": "ScriptError error message\nMOCK: update_status: rietveld-upload-queue ScriptError error message\nMOCK setting flag 'in-rietveld' to '-' on attachment '1234' with comment 'None' and additional comment 'None'\n",
    209213        }
    210214        self.assert_queue_outputs(RietveldUploadQueue(), expected_stderr=expected_stderr)
     
    219223            "process_work_item" : "MOCK: update_status: style-queue Pass\n",
    220224            "handle_unexpected_error" : "Mock error message\n",
    221         }
    222         self.assert_queue_outputs(StyleQueue(), expected_stderr=expected_stderr)
     225            "handle_script_error": "MOCK: update_status: style-queue ScriptError error message\nMOCK bug comment: bug_id=345, cc=[]\n--- Begin comment ---\\Attachment 1234 did not pass style-queue:\n\nScriptError error message\n\nIf any of these errors are false positives, please file a bug against check-webkit-style.\n--- End comment ---\n\n",
     226        }
     227        expected_exceptions = {
     228            "handle_script_error": SystemExit,
     229        }
     230        self.assert_queue_outputs(StyleQueue(), expected_stderr=expected_stderr, expected_exceptions=expected_exceptions)
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queuestest.py

    r57788 r60976  
    3131from webkitpy.common.net.bugzilla import Attachment
    3232from webkitpy.common.system.outputcapture import OutputCapture
     33from webkitpy.common.system.executive import ScriptError
    3334from webkitpy.thirdparty.mock import Mock
    3435from webkitpy.tool.mocktool import MockTool
     
    4344
    4445
     46class MockPatch():
     47    def id(self):
     48        return 1234
     49
     50    def bug_id(self):
     51        return 345
     52
     53
    4554class QueuesTest(unittest.TestCase):
    4655    mock_work_item = Attachment({
     
    5160    }, None)
    5261
    53     def assert_queue_outputs(self, queue, args=None, work_item=None, expected_stdout=None, expected_stderr=None, options=Mock(), tool=MockTool()):
     62    def assert_outputs(self, func, func_name, args, expected_stdout, expected_stderr, expected_exceptions):
     63        exception = None
     64        if expected_exceptions and func_name in expected_exceptions:
     65            exception = expected_exceptions[func_name]
     66
     67        OutputCapture().assert_outputs(self,
     68                func,
     69                args=args,
     70                expected_stdout=expected_stdout.get(func_name, ""),
     71                expected_stderr=expected_stderr.get(func_name, ""),
     72                expected_exception=exception)
     73
     74    def assert_queue_outputs(self, queue, args=None, work_item=None, expected_stdout=None, expected_stderr=None, expected_exceptions=None, options=Mock(), tool=MockTool()):
    5475        if not expected_stdout:
    5576            expected_stdout = {}
     
    6485        queue.execute(options, args, tool, engine=MockQueueEngine)
    6586
    66         OutputCapture().assert_outputs(self,
    67                 queue.queue_log_path,
    68                 expected_stdout=expected_stdout.get("queue_log_path", ""),
    69                 expected_stderr=expected_stderr.get("queue_log_path", ""))
    70         OutputCapture().assert_outputs(self,
    71                 queue.work_item_log_path,
    72                 args=[work_item],
    73                 expected_stdout=expected_stdout.get("work_item_log_path", ""),
    74                 expected_stderr=expected_stderr.get("work_item_log_path", ""))
    75         OutputCapture().assert_outputs(self,
    76                 queue.begin_work_queue,
    77                 expected_stdout=expected_stdout.get("begin_work_queue", ""),
    78                 expected_stderr=expected_stderr.get("begin_work_queue", ""))
    79         OutputCapture().assert_outputs(self,
    80                 queue.should_continue_work_queue,
    81                 expected_stdout=expected_stdout.get("should_continue_work_queue", ""), expected_stderr=expected_stderr.get("should_continue_work_queue", ""))
    82         OutputCapture().assert_outputs(self,
    83                 queue.next_work_item,
    84                 expected_stdout=expected_stdout.get("next_work_item", ""),
    85                 expected_stderr=expected_stderr.get("next_work_item", ""))
    86         OutputCapture().assert_outputs(self,
    87                 queue.should_proceed_with_work_item,
    88                 args=[work_item],
    89                 expected_stdout=expected_stdout.get("should_proceed_with_work_item", ""),
    90                 expected_stderr=expected_stderr.get("should_proceed_with_work_item", ""))
    91         OutputCapture().assert_outputs(self,
    92                 queue.process_work_item,
    93                 args=[work_item],
    94                 expected_stdout=expected_stdout.get("process_work_item", ""),
    95                 expected_stderr=expected_stderr.get("process_work_item", ""))
    96         OutputCapture().assert_outputs(self,
    97                 queue.handle_unexpected_error,
    98                 args=[work_item, "Mock error message"],
    99                 expected_stdout=expected_stdout.get("handle_unexpected_error", ""),
    100                 expected_stderr=expected_stderr.get("handle_unexpected_error", ""))
     87        self.assert_outputs(queue.queue_log_path, "queue_log_path", [], expected_stdout, expected_stderr, expected_exceptions)
     88        self.assert_outputs(queue.work_item_log_path, "work_item_log_path", [work_item], expected_stdout, expected_stderr, expected_exceptions)
     89        self.assert_outputs(queue.begin_work_queue, "begin_work_queue", [], expected_stdout, expected_stderr, expected_exceptions)
     90        self.assert_outputs(queue.should_continue_work_queue, "should_continue_work_queue", [], expected_stdout, expected_stderr, expected_exceptions)
     91        self.assert_outputs(queue.next_work_item, "next_work_item", [], expected_stdout, expected_stderr, expected_exceptions)
     92        self.assert_outputs(queue.should_proceed_with_work_item, "should_proceed_with_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions)
     93        self.assert_outputs(queue.process_work_item, "process_work_item", [work_item], expected_stdout, expected_stderr, expected_exceptions)
     94        self.assert_outputs(queue.handle_unexpected_error, "handle_unexpected_error", [work_item, "Mock error message"], expected_stdout, expected_stderr, expected_exceptions)
     95        self.assert_outputs(queue.handle_script_error, "handle_script_error", [tool, {"patch": MockPatch()}, ScriptError(message="ScriptError error message", script_args="MockErrorCommand")], expected_stdout, expected_stderr, expected_exceptions)
  • trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py

    r60924 r60976  
    513513        return 191
    514514
     515    def results_url_for_status(self, status_id):
     516        return "http://dummy_url"
    515517
    516518class MockExecute(Mock):
Note: See TracChangeset for help on using the changeset viewer.