Changeset 60976 in webkit
- Timestamp:
- Jun 10, 2010 2:55:34 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r60971 r60976 1 2010-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 1 15 2010-06-10 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com> 2 16 -
trunk/WebKitTools/Scripts/webkitpy/common/system/outputcapture.py
r56519 r60976 53 53 return (self._restore_output_with_name("stdout"), self._restore_output_with_name("stderr")) 54 54 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): 56 56 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) 58 61 (stdout_string, stderr_string) = self.restore_output() 59 62 testcase.assertEqual(stdout_string, expected_stdout) -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/earlywarningsystem_unittest.py
r59978 r60976 44 44 "name": ews.name, 45 45 "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, 46 48 } 47 49 expected_stderr = { … … 50 52 "next_work_item": "MOCK: update_work_items: %(name)s [103]\n" % string_replacemnts, 51 53 "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, 52 55 } 53 56 return expected_stderr 54 57 55 58 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) 57 63 58 64 # FIXME: If all EWSes are going to output the same text, we … … 74 80 expected_stderr = self._default_expected_stderr(ews) 75 81 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 332 332 raise e 333 333 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", "-") 336 337 337 338 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()) 339 341 340 342 # StepSequenceErrorHandler methods … … 342 344 @classmethod 343 345 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()) 346 349 347 350 -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py
r60924 r60976 129 129 "process_work_item" : "MOCK: update_status: commit-queue Pass\n", 130 130 "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", 131 132 } 132 133 self.assert_queue_outputs(CommitQueue(), expected_stderr=expected_stderr) … … 148 149 "process_work_item" : "MOCK: update_status: commit-queue Builders [\"Builder2\"] are red. See http://build.webkit.org\n", 149 150 "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", 150 152 } 151 153 self.assert_queue_outputs(CommitQueue(), tool=tool, expected_stderr=expected_stderr) … … 168 170 "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", 169 171 "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", 170 173 } 171 174 self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_stderr=expected_stderr) … … 206 209 "should_proceed_with_work_item": "MOCK: update_status: rietveld-upload-queue Uploading patch\n", 207 210 "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", 209 213 } 210 214 self.assert_queue_outputs(RietveldUploadQueue(), expected_stderr=expected_stderr) … … 219 223 "process_work_item" : "MOCK: update_status: style-queue Pass\n", 220 224 "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 31 31 from webkitpy.common.net.bugzilla import Attachment 32 32 from webkitpy.common.system.outputcapture import OutputCapture 33 from webkitpy.common.system.executive import ScriptError 33 34 from webkitpy.thirdparty.mock import Mock 34 35 from webkitpy.tool.mocktool import MockTool … … 43 44 44 45 46 class MockPatch(): 47 def id(self): 48 return 1234 49 50 def bug_id(self): 51 return 345 52 53 45 54 class QueuesTest(unittest.TestCase): 46 55 mock_work_item = Attachment({ … … 51 60 }, None) 52 61 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()): 54 75 if not expected_stdout: 55 76 expected_stdout = {} … … 64 85 queue.execute(options, args, tool, engine=MockQueueEngine) 65 86 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 513 513 return 191 514 514 515 def results_url_for_status(self, status_id): 516 return "http://dummy_url" 515 517 516 518 class MockExecute(Mock):
Note: See TracChangeset
for help on using the changeset viewer.