Update scripts to reference contributors.json instead of committers.py in messaging
[WebKit-https.git] / Tools / Scripts / webkitpy / tool / commands / queues_unittest.py
1 # Copyright (C) 2009 Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 #    * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 #    * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 #    * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import os
30 import StringIO
31
32 from webkitpy.common.checkout.scm import CheckoutNeedsUpdate
33 from webkitpy.common.checkout.scm.scm_mock import MockSCM
34 from webkitpy.common.net.bugzilla import Attachment
35 from webkitpy.common.system.outputcapture import OutputCapture
36 from webkitpy.layout_tests.models import test_results
37 from webkitpy.layout_tests.models import test_failures
38 from webkitpy.thirdparty.mock import Mock
39 from webkitpy.tool.commands.commandtest import CommandsTest
40 from webkitpy.tool.commands.queues import *
41 from webkitpy.tool.commands.queuestest import QueuesTest
42 from webkitpy.tool.commands.stepsequence import StepSequence
43 from webkitpy.common.net.statusserver_mock import MockStatusServer
44 from webkitpy.tool.mocktool import MockTool, MockOptions
45
46
47 class TestCommitQueue(CommitQueue):
48     def __init__(self, tool=None):
49         CommitQueue.__init__(self)
50         if tool:
51             self.bind_to_tool(tool)
52         self._options = MockOptions(confirm=False, parent_command="commit-queue", port=None)
53
54     def begin_work_queue(self):
55         output_capture = OutputCapture()
56         output_capture.capture_output()
57         CommitQueue.begin_work_queue(self)
58         output_capture.restore_output()
59
60
61 class TestQueue(AbstractPatchQueue):
62     name = "test-queue"
63
64
65 class TestReviewQueue(AbstractReviewQueue):
66     name = "test-review-queue"
67
68
69 class TestFeederQueue(FeederQueue):
70     _sleep_duration = 0
71
72
73 class AbstractQueueTest(CommandsTest):
74     def test_log_directory(self):
75         self.assertEqual(TestQueue()._log_directory(), os.path.join("..", "test-queue-logs"))
76
77     def _assert_run_webkit_patch(self, run_args, port=None):
78         queue = TestQueue()
79         tool = MockTool()
80         tool.status_server.bot_id = "gort"
81         tool.executive = Mock()
82         queue.bind_to_tool(tool)
83         queue._options = Mock()
84         queue._options.port = port
85
86         queue.run_webkit_patch(run_args)
87         expected_run_args = ["echo", "--status-host=example.com", "--bot-id=gort"]
88         if port:
89             expected_run_args.append("--port=%s" % port)
90         expected_run_args.extend(run_args)
91         tool.executive.run_command.assert_called_with(expected_run_args, cwd='/mock-checkout')
92
93     def test_run_webkit_patch(self):
94         self._assert_run_webkit_patch([1])
95         self._assert_run_webkit_patch(["one", 2])
96         self._assert_run_webkit_patch([1], port="mockport")
97
98     def test_iteration_count(self):
99         queue = TestQueue()
100         queue._options = Mock()
101         queue._options.iterations = 3
102         self.assertTrue(queue.should_continue_work_queue())
103         self.assertTrue(queue.should_continue_work_queue())
104         self.assertTrue(queue.should_continue_work_queue())
105         self.assertFalse(queue.should_continue_work_queue())
106
107     def test_no_iteration_count(self):
108         queue = TestQueue()
109         queue._options = Mock()
110         self.assertTrue(queue.should_continue_work_queue())
111         self.assertTrue(queue.should_continue_work_queue())
112         self.assertTrue(queue.should_continue_work_queue())
113         self.assertTrue(queue.should_continue_work_queue())
114
115     def _assert_log_message(self, script_error, log_message):
116         failure_log = AbstractQueue._log_from_script_error_for_upload(script_error, output_limit=10)
117         self.assertTrue(failure_log.read(), log_message)
118
119     def test_log_from_script_error_for_upload(self):
120         self._assert_log_message(ScriptError("test"), "test")
121         unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
122         utf8_tor = unicode_tor.encode("utf-8")
123         self._assert_log_message(ScriptError(unicode_tor), utf8_tor)
124         script_error = ScriptError(unicode_tor, output=unicode_tor)
125         expected_output = "%s\nLast %s characters of output:\n%s" % (utf8_tor, 10, utf8_tor[-10:])
126         self._assert_log_message(script_error, expected_output)
127
128
129 class FeederQueueTest(QueuesTest):
130     def test_feeder_queue(self):
131         queue = TestFeederQueue()
132         tool = MockTool(log_executive=True)
133         expected_logs = {
134             "begin_work_queue": self._default_begin_work_queue_logs("feeder-queue"),
135             "process_work_item": """Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
136 Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
137 MOCK setting flag 'commit-queue' to '-' on attachment '10001' with comment 'Rejecting attachment 10001 from commit-queue.\n\nnon-committer@example.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json.
138
139 - If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.
140
141 - If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your committer rights.'
142 MOCK: update_work_items: commit-queue [10005, 10000]
143 Feeding commit-queue items [10005, 10000]
144 Feeding EWS (1 r? patch, 1 new)
145 MOCK: submit_to_ews: 10002
146 """,
147             "handle_unexpected_error": "Mock error message\n",
148         }
149         self.assert_queue_outputs(queue, tool=tool, expected_logs=expected_logs)
150
151
152 class AbstractPatchQueueTest(CommandsTest):
153     def test_next_patch(self):
154         queue = AbstractPatchQueue()
155         tool = MockTool()
156         queue.bind_to_tool(tool)
157         queue._options = Mock()
158         queue._options.port = None
159         self.assertIsNone(queue._next_patch())
160         tool.status_server = MockStatusServer(work_items=[2, 10000, 10001])
161         expected_stdout = "MOCK: fetch_attachment: 2 is not a known attachment id\n"  # A mock-only message to prevent us from making mistakes.
162         expected_logs = "MOCK: release_work_item: None 2\n"
163         patch = OutputCapture().assert_outputs(self, queue._next_patch, expected_stdout=expected_stdout, expected_logs=expected_logs)
164         # The patch.id() == 2 is ignored because it doesn't exist.
165         self.assertEqual(patch.id(), 10000)
166         self.assertEqual(queue._next_patch().id(), 10001)
167         self.assertEqual(queue._next_patch(), None)    # When the queue is empty
168
169
170 class PatchProcessingQueueTest(CommandsTest):
171     def test_upload_results_archive_for_patch(self):
172         queue = PatchProcessingQueue()
173         queue.name = "mock-queue"
174         tool = MockTool()
175         queue.bind_to_tool(tool)
176         queue._options = Mock()
177         queue._options.port = None
178         patch = queue._tool.bugs.fetch_attachment(10001)
179         expected_logs = """MOCK add_attachment_to_bug: bug_id=50000, description=Archive of layout-test-results from bot for mac-snowleopard filename=layout-test-results.zip mimetype=None
180 -- Begin comment --
181 The attached test failures were seen while running run-webkit-tests on the mock-queue.
182 Port: mac-snowleopard  Platform: MockPlatform 1.0
183 -- End comment --
184 """
185         OutputCapture().assert_outputs(self, queue._upload_results_archive_for_patch, [patch, Mock()], expected_logs=expected_logs)
186
187
188 class NeedsUpdateSequence(StepSequence):
189     def _run(self, tool, options, state):
190         raise CheckoutNeedsUpdate([], 1, "", None)
191
192
193 class AlwaysCommitQueueTool(object):
194     def __init__(self):
195         self.status_server = MockStatusServer()
196
197     def command_by_name(self, name):
198         return CommitQueue
199
200
201 class SecondThoughtsCommitQueue(TestCommitQueue):
202     def __init__(self, tool=None):
203         self._reject_patch = False
204         TestCommitQueue.__init__(self, tool)
205
206     def run_command(self, command):
207         # We want to reject the patch after the first validation,
208         # so wait to reject it until after some other command has run.
209         self._reject_patch = True
210         return CommitQueue.run_command(self, command)
211
212     def refetch_patch(self, patch):
213         if not self._reject_patch:
214             return self._tool.bugs.fetch_attachment(patch.id())
215
216         attachment_dictionary = {
217             "id": patch.id(),
218             "bug_id": patch.bug_id(),
219             "name": "Rejected",
220             "is_obsolete": True,
221             "is_patch": False,
222             "review": "-",
223             "reviewer_email": "foo@bar.com",
224             "commit-queue": "-",
225             "committer_email": "foo@bar.com",
226             "attacher_email": "Contributer1",
227         }
228         return Attachment(attachment_dictionary, None)
229
230
231 class CommitQueueTest(QueuesTest):
232     def _mock_test_result(self, testname):
233         return test_results.TestResult(testname, [test_failures.FailureTextMismatch()])
234
235     def test_commit_queue(self):
236         tool = MockTool()
237         tool.filesystem.write_text_file('/tmp/layout-test-results/full_results.json', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
238         tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
239         expected_logs = {
240             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
241             "process_work_item": """Running: webkit-patch --status-host=example.com clean --port=mac
242 MOCK: update_status: commit-queue Cleaned working directory
243 Running: webkit-patch --status-host=example.com update --port=mac
244 MOCK: update_status: commit-queue Updated working directory
245 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000 --port=mac
246 MOCK: update_status: commit-queue Applied patch
247 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10000 --port=mac
248 MOCK: update_status: commit-queue ChangeLog validated
249 Running: webkit-patch --status-host=example.com build --no-clean --no-update --build-style=release --port=mac
250 MOCK: update_status: commit-queue Built patch
251 Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=mac
252 MOCK: update_status: commit-queue Passed tests
253 Running: webkit-patch --status-host=example.com land-attachment --force-clean --non-interactive --parent-command=commit-queue 10000 --port=mac
254 MOCK: update_status: commit-queue Landed patch
255 MOCK: update_status: commit-queue Pass
256 MOCK: release_work_item: commit-queue 10000
257 """,
258             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
259             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
260         }
261         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
262
263     def test_commit_queue_failure(self):
264         expected_logs = {
265             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
266             "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
267 MOCK: update_status: commit-queue Updated working directory
268 MOCK: update_status: commit-queue Patch does not apply
269 MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMOCK script error
270 Full output: http://dummy_url'
271 MOCK: update_status: commit-queue Fail
272 MOCK: release_work_item: commit-queue 10000
273 """,
274             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
275             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
276         }
277         queue = CommitQueue()
278
279         def mock_run_webkit_patch(command):
280             if command[0] == 'clean' or command[0] == 'update':
281                 # We want cleaning to succeed so we can error out on a step
282                 # that causes the commit-queue to reject the patch.
283                 return
284             raise ScriptError('MOCK script error')
285
286         queue.run_webkit_patch = mock_run_webkit_patch
287         self.assert_queue_outputs(queue, expected_logs=expected_logs)
288
289     def test_commit_queue_failure_with_failing_tests(self):
290         expected_logs = {
291             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
292             "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
293 MOCK: update_status: commit-queue Updated working directory
294 MOCK: update_status: commit-queue Patch does not apply
295 MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nNew failing tests:
296 mock_test_name.html
297 another_test_name.html
298 Full output: http://dummy_url'
299 MOCK: update_status: commit-queue Fail
300 MOCK: release_work_item: commit-queue 10000
301 """,
302             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
303             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
304         }
305         queue = CommitQueue()
306
307         def mock_run_webkit_patch(command):
308             if command[0] == 'clean' or command[0] == 'update':
309                 # We want cleaning to succeed so we can error out on a step
310                 # that causes the commit-queue to reject the patch.
311                 return
312             queue._expected_failures.unexpected_failures_observed = lambda results: ["mock_test_name.html", "another_test_name.html"]
313             raise ScriptError('MOCK script error')
314
315         queue.run_webkit_patch = mock_run_webkit_patch
316         self.assert_queue_outputs(queue, expected_logs=expected_logs)
317
318     def test_rollout(self):
319         tool = MockTool()
320         tool.filesystem.write_text_file('/tmp/layout-test-results/full_results.json', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
321         tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
322         tool.buildbot.light_tree_on_fire()
323         expected_logs = {
324             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
325             "process_work_item": """Running: webkit-patch --status-host=example.com clean --port=%(port)s
326 MOCK: update_status: commit-queue Cleaned working directory
327 Running: webkit-patch --status-host=example.com update --port=%(port)s
328 MOCK: update_status: commit-queue Updated working directory
329 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000 --port=%(port)s
330 MOCK: update_status: commit-queue Applied patch
331 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10000 --port=%(port)s
332 MOCK: update_status: commit-queue ChangeLog validated
333 Running: webkit-patch --status-host=example.com build --no-clean --no-update --build-style=release --port=%(port)s
334 MOCK: update_status: commit-queue Built patch
335 Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=%(port)s
336 MOCK: update_status: commit-queue Passed tests
337 Running: webkit-patch --status-host=example.com land-attachment --force-clean --non-interactive --parent-command=commit-queue 10000 --port=%(port)s
338 MOCK: update_status: commit-queue Landed patch
339 MOCK: update_status: commit-queue Pass
340 MOCK: release_work_item: commit-queue 10000
341 """ % {"port": "mac"},
342             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
343             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMock error message'\n",
344         }
345         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
346
347     def test_rollout_lands(self):
348         tool = MockTool()
349         tool.buildbot.light_tree_on_fire()
350         rollout_patch = tool.bugs.fetch_attachment(10005)  # _patch6, a rollout patch.
351         assert(rollout_patch.is_rollout())
352         expected_logs = {
353             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
354             "process_work_item": """Running: webkit-patch --status-host=example.com clean --port=%(port)s
355 MOCK: update_status: commit-queue Cleaned working directory
356 Running: webkit-patch --status-host=example.com update --port=%(port)s
357 MOCK: update_status: commit-queue Updated working directory
358 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10005 --port=%(port)s
359 MOCK: update_status: commit-queue Applied patch
360 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10005 --port=%(port)s
361 MOCK: update_status: commit-queue ChangeLog validated
362 Running: webkit-patch --status-host=example.com land-attachment --force-clean --non-interactive --parent-command=commit-queue 10005 --port=%(port)s
363 MOCK: update_status: commit-queue Landed patch
364 MOCK: update_status: commit-queue Pass
365 MOCK: release_work_item: commit-queue 10005
366 """ % {"port": "mac"},
367             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
368             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10005' with comment 'Rejecting attachment 10005 from commit-queue.\n\nMock error message'\n",
369         }
370         self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_logs=expected_logs)
371
372     def test_auto_retry(self):
373         queue = CommitQueue()
374         options = Mock()
375         options.parent_command = "commit-queue"
376         tool = AlwaysCommitQueueTool()
377         sequence = NeedsUpdateSequence(None)
378
379         expected_logs = """Commit failed because the checkout is out of date. Please update and try again.
380 MOCK: update_status: commit-queue Tests passed, but commit failed (checkout out of date).  Updating, then landing without building or re-running tests.
381 """
382         state = {'patch': None}
383         OutputCapture().assert_outputs(self, sequence.run_and_handle_errors, [tool, options, state], expected_exception=TryAgain, expected_logs=expected_logs)
384
385         self.assertTrue(options.update)
386         self.assertFalse(options.build)
387         self.assertFalse(options.test)
388
389     def test_manual_reject_during_processing(self):
390         queue = SecondThoughtsCommitQueue(MockTool())
391         queue.begin_work_queue()
392         queue._tool.filesystem.write_text_file('/tmp/layout-test-results/full_results.json', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
393         queue._tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
394         queue._options = Mock()
395         queue._options.port = None
396         expected_logs = """Running: webkit-patch --status-host=example.com clean --port=mac
397 MOCK: update_status: commit-queue Cleaned working directory
398 Running: webkit-patch --status-host=example.com update --port=mac
399 MOCK: update_status: commit-queue Updated working directory
400 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000 --port=mac
401 MOCK: update_status: commit-queue Applied patch
402 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10000 --port=mac
403 MOCK: update_status: commit-queue ChangeLog validated
404 Running: webkit-patch --status-host=example.com build --no-clean --no-update --build-style=release --port=mac
405 MOCK: update_status: commit-queue Built patch
406 Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=mac
407 MOCK: update_status: commit-queue Passed tests
408 MOCK: update_status: commit-queue Retry
409 MOCK: release_work_item: commit-queue 10000
410 """
411         self.maxDiff = None
412         OutputCapture().assert_outputs(self, queue.process_work_item, [QueuesTest.mock_work_item], expected_logs=expected_logs)
413
414     def test_report_flaky_tests(self):
415         queue = TestCommitQueue(MockTool())
416         expected_logs = """MOCK bug comment: bug_id=50002, cc=None
417 --- Begin comment ---
418 The commit-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000.
419 Port: MockPort  Platform: MockPlatform 1.0
420 --- End comment ---
421
422 MOCK add_attachment_to_bug: bug_id=50002, description=Failure diff from bot filename=failure.diff mimetype=None
423 MOCK bug comment: bug_id=50002, cc=None
424 --- Begin comment ---
425 The commit-queue just saw bar/baz.html flake (text diff) while processing attachment 10000 on bug 50000.
426 Port: MockPort  Platform: MockPlatform 1.0
427 --- End comment ---
428
429 bar/baz-diffs.txt does not exist in results archive, uploading entire archive.
430 MOCK add_attachment_to_bug: bug_id=50002, description=Archive of layout-test-results from bot filename=layout-test-results.zip mimetype=None
431 MOCK bug comment: bug_id=50000, cc=None
432 --- Begin comment ---
433 The commit-queue encountered the following flaky tests while processing attachment 10000:
434
435 foo/bar.html bug 50002 (author: abarth@webkit.org)
436 bar/baz.html bug 50002 (author: abarth@webkit.org)
437 The commit-queue is continuing to process your patch.
438 --- End comment ---
439
440 """
441         test_names = ["foo/bar.html", "bar/baz.html"]
442         test_results = [self._mock_test_result(name) for name in test_names]
443
444         class MockZipFile(object):
445             def __init__(self):
446                 self.fp = StringIO()
447
448             def read(self, path):
449                 return ""
450
451             def namelist(self):
452                 # This is intentionally missing one diffs.txt to exercise the "upload the whole zip" codepath.
453                 return ['foo/bar-diffs.txt']
454
455         OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results, MockZipFile()], expected_logs=expected_logs)
456
457     def test_did_pass_testing_ews(self):
458         tool = MockTool()
459         patch = tool.bugs.fetch_attachment(10000)
460         queue = TestCommitQueue(tool)
461         self.assertFalse(queue.did_pass_testing_ews(patch))
462
463
464 class StyleQueueTest(QueuesTest):
465     def test_style_queue_with_style_exception(self):
466         expected_logs = {
467             "begin_work_queue": self._default_begin_work_queue_logs("style-queue"),
468             "process_work_item": """Running: webkit-patch --status-host=example.com clean
469 MOCK: update_status: style-queue Cleaned working directory
470 Running: webkit-patch --status-host=example.com update
471 MOCK: update_status: style-queue Updated working directory
472 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000
473 MOCK: update_status: style-queue Applied patch
474 Running: webkit-patch --status-host=example.com apply-watchlist-local 50000
475 MOCK: update_status: style-queue Watchlist applied
476 Running: webkit-patch --status-host=example.com check-style-local --non-interactive --quiet
477 MOCK: update_status: style-queue Style checked
478 MOCK: update_status: style-queue Pass
479 MOCK: release_work_item: style-queue 10000
480 """,
481             "handle_unexpected_error": "Mock error message\n",
482             "handle_script_error": "MOCK output\n",
483         }
484         tool = MockTool(executive_throws_when_run=set(['check-style']))
485         self.assert_queue_outputs(StyleQueue(), expected_logs=expected_logs, tool=tool)
486
487     def test_style_queue_with_watch_list_exception(self):
488         expected_logs = {
489             "begin_work_queue": self._default_begin_work_queue_logs("style-queue"),
490             "process_work_item": """Running: webkit-patch --status-host=example.com clean
491 MOCK: update_status: style-queue Cleaned working directory
492 Running: webkit-patch --status-host=example.com update
493 MOCK: update_status: style-queue Updated working directory
494 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000
495 MOCK: update_status: style-queue Applied patch
496 Running: webkit-patch --status-host=example.com apply-watchlist-local 50000
497 Exception for ['echo', '--status-host=example.com', 'apply-watchlist-local', 50000]
498
499 MOCK command output
500 MOCK: update_status: style-queue Unabled to apply watchlist
501 Running: webkit-patch --status-host=example.com check-style-local --non-interactive --quiet
502 MOCK: update_status: style-queue Style checked
503 MOCK: update_status: style-queue Pass
504 MOCK: release_work_item: style-queue 10000
505 """,
506             "handle_unexpected_error": "Mock error message\n",
507             "handle_script_error": "MOCK output\n",
508         }
509         tool = MockTool(executive_throws_when_run=set(['apply-watchlist-local']))
510         self.assert_queue_outputs(StyleQueue(), expected_logs=expected_logs, tool=tool)