b9f718dc00a8825737bdb0ecc83d91f02191533b
[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.layouttestresults import LayoutTestResults
35 from webkitpy.common.net.bugzilla import Attachment
36 from webkitpy.common.system.outputcapture import OutputCapture
37 from webkitpy.layout_tests.models import test_results
38 from webkitpy.layout_tests.models import test_failures
39 from webkitpy.thirdparty.mock import Mock
40 from webkitpy.tool.commands.commandtest import CommandsTest
41 from webkitpy.tool.commands.queues import *
42 from webkitpy.tool.commands.queuestest import QueuesTest
43 from webkitpy.tool.commands.stepsequence import StepSequence
44 from webkitpy.common.net.statusserver_mock import MockStatusServer
45 from webkitpy.tool.mocktool import MockTool, MockOptions
46
47
48 class TestCommitQueue(CommitQueue):
49     def __init__(self, tool=None):
50         CommitQueue.__init__(self)
51         if tool:
52             self.bind_to_tool(tool)
53         self._options = MockOptions(confirm=False, parent_command="commit-queue", port=None)
54
55     def begin_work_queue(self):
56         output_capture = OutputCapture()
57         output_capture.capture_output()
58         CommitQueue.begin_work_queue(self)
59         output_capture.restore_output()
60
61
62 class TestQueue(AbstractPatchQueue):
63     name = "test-queue"
64
65
66 class TestReviewQueue(AbstractReviewQueue):
67     name = "test-review-queue"
68
69
70 class TestFeederQueue(FeederQueue):
71     _sleep_duration = 0
72
73
74 class AbstractQueueTest(CommandsTest):
75     def test_log_directory(self):
76         self.assertEqual(TestQueue()._log_directory(), os.path.join("..", "test-queue-logs"))
77
78     def _assert_run_webkit_patch(self, run_args, port=None):
79         queue = TestQueue()
80         tool = MockTool()
81         tool.status_server.bot_id = "gort"
82         tool.executive = Mock()
83         queue.bind_to_tool(tool)
84         queue._options = Mock()
85         queue._options.port = port
86
87         queue.run_webkit_patch(run_args)
88         expected_run_args = ["echo", "--status-host=example.com", "--bot-id=gort"]
89         if port:
90             expected_run_args.append("--port=%s" % port)
91         expected_run_args.extend(run_args)
92         tool.executive.run_command.assert_called_with(expected_run_args, cwd='/mock-checkout')
93
94     def test_run_webkit_patch(self):
95         self._assert_run_webkit_patch([1])
96         self._assert_run_webkit_patch(["one", 2])
97         self._assert_run_webkit_patch([1], port="mockport")
98
99     def test_iteration_count(self):
100         queue = TestQueue()
101         queue._options = Mock()
102         queue._options.iterations = 3
103         self.assertTrue(queue.should_continue_work_queue())
104         self.assertTrue(queue.should_continue_work_queue())
105         self.assertTrue(queue.should_continue_work_queue())
106         self.assertFalse(queue.should_continue_work_queue())
107
108     def test_no_iteration_count(self):
109         queue = TestQueue()
110         queue._options = Mock()
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         self.assertTrue(queue.should_continue_work_queue())
115
116     def _assert_log_message(self, script_error, log_message):
117         failure_log = AbstractQueue._log_from_script_error_for_upload(script_error, output_limit=10)
118         self.assertTrue(failure_log.read(), log_message)
119
120     def test_log_from_script_error_for_upload(self):
121         self._assert_log_message(ScriptError("test"), "test")
122         unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
123         utf8_tor = unicode_tor.encode("utf-8")
124         self._assert_log_message(ScriptError(unicode_tor), utf8_tor)
125         script_error = ScriptError(unicode_tor, output=unicode_tor)
126         expected_output = "%s\nLast %s characters of output:\n%s" % (utf8_tor, 10, utf8_tor[-10:])
127         self._assert_log_message(script_error, expected_output)
128
129
130 class FeederQueueTest(QueuesTest):
131     def test_feeder_queue(self):
132         self.maxDiff = None
133         queue = TestFeederQueue()
134         tool = MockTool(log_executive=True)
135         expected_logs = {
136             "begin_work_queue": self._default_begin_work_queue_logs("feeder-queue"),
137             "process_work_item": """Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
138 Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
139 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.
140
141 - If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.
142
143 - 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.'
144 Feeding commit-queue high priority items [10005], regular items [10000]
145 MOCK: update_work_items: commit-queue [10005, 10000]
146 Feeding EWS (1 r? patch, 1 new)
147 MOCK: submit_to_ews: 10002
148 """,
149             "handle_unexpected_error": "Mock error message\n",
150         }
151         self.assert_queue_outputs(queue, tool=tool, expected_logs=expected_logs)
152
153
154 class AbstractPatchQueueTest(CommandsTest):
155     def test_next_patch(self):
156         queue = AbstractPatchQueue()
157         tool = MockTool()
158         queue.bind_to_tool(tool)
159         queue._options = Mock()
160         queue._options.port = None
161         self.assertIsNone(queue._next_patch())
162         tool.status_server = MockStatusServer(work_items=[2, 10000, 10001])
163         expected_stdout = "MOCK: fetch_attachment: 2 is not a known attachment id\n"  # A mock-only message to prevent us from making mistakes.
164         expected_logs = "MOCK: release_work_item: None 2\n"
165         patch = OutputCapture().assert_outputs(self, queue._next_patch, expected_stdout=expected_stdout, expected_logs=expected_logs)
166         # The patch.id() == 2 is ignored because it doesn't exist.
167         self.assertEqual(patch.id(), 10000)
168         self.assertEqual(queue._next_patch().id(), 10001)
169         self.assertEqual(queue._next_patch(), None)    # When the queue is empty
170
171
172 class PatchProcessingQueueTest(CommandsTest):
173     def test_upload_results_archive_for_patch(self):
174         queue = PatchProcessingQueue()
175         queue.name = "mock-queue"
176         tool = MockTool()
177         queue.bind_to_tool(tool)
178         queue._options = Mock()
179         queue._options.port = None
180         patch = queue._tool.bugs.fetch_attachment(10001)
181         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
182 -- Begin comment --
183 The attached test failures were seen while running run-webkit-tests on the mock-queue.
184 Port: mac-snowleopard  Platform: MockPlatform 1.0
185 -- End comment --
186 """
187         OutputCapture().assert_outputs(self, queue._upload_results_archive_for_patch, [patch, Mock()], expected_logs=expected_logs)
188
189
190 class NeedsUpdateSequence(StepSequence):
191     def _run(self, tool, options, state):
192         raise CheckoutNeedsUpdate([], 1, "", None)
193
194
195 class AlwaysCommitQueueTool(object):
196     def __init__(self):
197         self.status_server = MockStatusServer()
198
199     def command_by_name(self, name):
200         return CommitQueue
201
202
203 class SecondThoughtsCommitQueue(TestCommitQueue):
204     def __init__(self, tool=None):
205         self._reject_patch = False
206         TestCommitQueue.__init__(self, tool)
207
208     def run_command(self, command):
209         # We want to reject the patch after the first validation,
210         # so wait to reject it until after some other command has run.
211         self._reject_patch = True
212         return CommitQueue.run_command(self, command)
213
214     def refetch_patch(self, patch):
215         if not self._reject_patch:
216             return self._tool.bugs.fetch_attachment(patch.id())
217
218         attachment_dictionary = {
219             "id": patch.id(),
220             "bug_id": patch.bug_id(),
221             "name": "Rejected",
222             "is_obsolete": True,
223             "is_patch": False,
224             "review": "-",
225             "reviewer_email": "foo@bar.com",
226             "commit-queue": "-",
227             "committer_email": "foo@bar.com",
228             "attacher_email": "Contributer1",
229         }
230         return Attachment(attachment_dictionary, None)
231
232
233 class CommitQueueTest(QueuesTest):
234     def _mock_test_result(self, testname):
235         return test_results.TestResult(testname, [test_failures.FailureTextMismatch()])
236
237     def test_commit_queue(self):
238         tool = MockTool()
239         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.
240         tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
241         expected_logs = {
242             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
243             "process_work_item": """Running: webkit-patch --status-host=example.com clean --port=mac
244 MOCK: update_status: commit-queue Cleaned working directory
245 Running: webkit-patch --status-host=example.com update --port=mac
246 MOCK: update_status: commit-queue Updated working directory
247 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000 --port=mac
248 MOCK: update_status: commit-queue Applied patch
249 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10000 --port=mac
250 MOCK: update_status: commit-queue ChangeLog validated
251 Running: webkit-patch --status-host=example.com build --no-clean --no-update --build-style=release --port=mac
252 MOCK: update_status: commit-queue Built patch
253 Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=mac
254 MOCK: update_status: commit-queue Passed tests
255 Running: webkit-patch --status-host=example.com land-attachment --force-clean --non-interactive --parent-command=commit-queue 10000 --port=mac
256 MOCK: update_status: commit-queue Landed patch
257 MOCK: update_status: commit-queue Pass
258 MOCK: release_work_item: commit-queue 10000
259 """,
260             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
261             "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",
262         }
263         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
264
265     def test_commit_queue_failure(self):
266         expected_logs = {
267             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
268             "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
269 MOCK: update_status: commit-queue Updated working directory
270 MOCK: update_status: commit-queue Patch does not apply
271 MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nMOCK script error
272 Full output: http://dummy_url'
273 MOCK: update_status: commit-queue Fail
274 MOCK: release_work_item: commit-queue 10000
275 """,
276             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
277             "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",
278         }
279         queue = CommitQueue()
280
281         def mock_run_webkit_patch(command):
282             if command[0] == 'clean' or command[0] == 'update':
283                 # We want cleaning to succeed so we can error out on a step
284                 # that causes the commit-queue to reject the patch.
285                 return
286             raise ScriptError('MOCK script error')
287
288         queue.run_webkit_patch = mock_run_webkit_patch
289         self.assert_queue_outputs(queue, expected_logs=expected_logs)
290
291     def test_commit_queue_failure_with_failing_tests(self):
292         expected_logs = {
293             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
294             "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
295 MOCK: update_status: commit-queue Updated working directory
296 MOCK: update_status: commit-queue Patch does not apply
297 MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.\n\nNew failing tests:
298 mock_test_name.html
299 Full output: http://dummy_url'
300 MOCK: update_status: commit-queue Fail
301 MOCK: release_work_item: commit-queue 10000
302 """,
303             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
304             "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",
305         }
306
307         class MockCommitQueueTask(CommitQueueTask):
308             def results_from_patch_test_run(self, patch):
309                 return LayoutTestResults([test_results.TestResult("mock_test_name.html", failures=[test_failures.FailureTextMismatch()])], did_exceed_test_failure_limit=False)
310
311         queue = CommitQueue(MockCommitQueueTask)
312
313         def mock_run_webkit_patch(command):
314             if command[0] == 'clean' or command[0] == 'update':
315                 # We want cleaning to succeed so we can error out on a step
316                 # that causes the commit-queue to reject the patch.
317                 return
318             raise ScriptError('MOCK script error')
319
320         queue.run_webkit_patch = mock_run_webkit_patch
321         self.assert_queue_outputs(queue, expected_logs=expected_logs)
322
323     def test_rollout(self):
324         tool = MockTool()
325         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.
326         tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
327         tool.buildbot.light_tree_on_fire()
328         expected_logs = {
329             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
330             "process_work_item": """Running: webkit-patch --status-host=example.com clean --port=%(port)s
331 MOCK: update_status: commit-queue Cleaned working directory
332 Running: webkit-patch --status-host=example.com update --port=%(port)s
333 MOCK: update_status: commit-queue Updated working directory
334 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000 --port=%(port)s
335 MOCK: update_status: commit-queue Applied patch
336 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10000 --port=%(port)s
337 MOCK: update_status: commit-queue ChangeLog validated
338 Running: webkit-patch --status-host=example.com build --no-clean --no-update --build-style=release --port=%(port)s
339 MOCK: update_status: commit-queue Built patch
340 Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=%(port)s
341 MOCK: update_status: commit-queue Passed tests
342 Running: webkit-patch --status-host=example.com land-attachment --force-clean --non-interactive --parent-command=commit-queue 10000 --port=%(port)s
343 MOCK: update_status: commit-queue Landed patch
344 MOCK: update_status: commit-queue Pass
345 MOCK: release_work_item: commit-queue 10000
346 """ % {"port": "mac"},
347             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
348             "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",
349         }
350         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_logs=expected_logs)
351
352     def test_rollout_lands(self):
353         tool = MockTool()
354         tool.buildbot.light_tree_on_fire()
355         rollout_patch = tool.bugs.fetch_attachment(10005)  # _patch6, a rollout patch.
356         assert(rollout_patch.is_rollout())
357         expected_logs = {
358             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
359             "process_work_item": """Running: webkit-patch --status-host=example.com clean --port=%(port)s
360 MOCK: update_status: commit-queue Cleaned working directory
361 Running: webkit-patch --status-host=example.com update --port=%(port)s
362 MOCK: update_status: commit-queue Updated working directory
363 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10005 --port=%(port)s
364 MOCK: update_status: commit-queue Applied patch
365 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10005 --port=%(port)s
366 MOCK: update_status: commit-queue ChangeLog validated
367 Running: webkit-patch --status-host=example.com land-attachment --force-clean --non-interactive --parent-command=commit-queue 10005 --port=%(port)s
368 MOCK: update_status: commit-queue Landed patch
369 MOCK: update_status: commit-queue Pass
370 MOCK: release_work_item: commit-queue 10005
371 """ % {"port": "mac"},
372             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
373             "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",
374         }
375         self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_logs=expected_logs)
376
377     def test_non_valid_patch(self):
378         tool = MockTool()
379         patch = tool.bugs.fetch_attachment(10007)  # _patch8, resolved bug, without review flag, not marked obsolete (maybe already landed)
380         expected_logs = {
381             "begin_work_queue": self._default_begin_work_queue_logs("commit-queue"),
382             "process_work_item": """MOCK: update_status: commit-queue Error: commit-queue did not process patch.
383 MOCK: release_work_item: commit-queue 10007
384 """,
385         }
386         self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=patch, expected_logs=expected_logs)
387
388
389     def test_auto_retry(self):
390         queue = CommitQueue()
391         options = Mock()
392         options.parent_command = "commit-queue"
393         tool = AlwaysCommitQueueTool()
394         sequence = NeedsUpdateSequence(None)
395
396         expected_logs = """Commit failed because the checkout is out of date. Please update and try again.
397 MOCK: update_status: commit-queue Tests passed, but commit failed (checkout out of date).  Updating, then landing without building or re-running tests.
398 """
399         state = {'patch': None}
400         OutputCapture().assert_outputs(self, sequence.run_and_handle_errors, [tool, options, state], expected_exception=TryAgain, expected_logs=expected_logs)
401
402         self.assertTrue(options.update)
403         self.assertFalse(options.build)
404         self.assertFalse(options.test)
405
406     def test_manual_reject_during_processing(self):
407         queue = SecondThoughtsCommitQueue(MockTool())
408         queue.begin_work_queue()
409         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.
410         queue._tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
411         queue._options = Mock()
412         queue._options.port = None
413         expected_logs = """Running: webkit-patch --status-host=example.com clean --port=mac
414 MOCK: update_status: commit-queue Cleaned working directory
415 Running: webkit-patch --status-host=example.com update --port=mac
416 MOCK: update_status: commit-queue Updated working directory
417 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000 --port=mac
418 MOCK: update_status: commit-queue Applied patch
419 Running: webkit-patch --status-host=example.com validate-changelog --check-oops --non-interactive 10000 --port=mac
420 MOCK: update_status: commit-queue ChangeLog validated
421 Running: webkit-patch --status-host=example.com build --no-clean --no-update --build-style=release --port=mac
422 MOCK: update_status: commit-queue Built patch
423 Running: webkit-patch --status-host=example.com build-and-test --no-clean --no-update --test --non-interactive --port=mac
424 MOCK: update_status: commit-queue Passed tests
425 MOCK: update_status: commit-queue Error: commit-queue did not process patch.
426 MOCK: release_work_item: commit-queue 10000
427 """
428         self.maxDiff = None
429         OutputCapture().assert_outputs(self, queue.process_work_item, [QueuesTest.mock_work_item], expected_logs=expected_logs)
430
431     def test_report_flaky_tests(self):
432         queue = TestCommitQueue(MockTool())
433         expected_logs = """MOCK bug comment: bug_id=50002, cc=None
434 --- Begin comment ---
435 The commit-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000.
436 Port: MockPort  Platform: MockPlatform 1.0
437 --- End comment ---
438
439 MOCK add_attachment_to_bug: bug_id=50002, description=Failure diff from bot filename=failure.diff mimetype=None
440 MOCK bug comment: bug_id=50002, cc=None
441 --- Begin comment ---
442 The commit-queue just saw bar/baz.html flake (text diff) while processing attachment 10000 on bug 50000.
443 Port: MockPort  Platform: MockPlatform 1.0
444 --- End comment ---
445
446 bar/baz-diffs.txt does not exist in results archive, uploading entire archive.
447 MOCK add_attachment_to_bug: bug_id=50002, description=Archive of layout-test-results from bot filename=layout-test-results.zip mimetype=None
448 MOCK bug comment: bug_id=50000, cc=None
449 --- Begin comment ---
450 The commit-queue encountered the following flaky tests while processing attachment 10000:
451
452 foo/bar.html bug 50002 (author: abarth@webkit.org)
453 bar/baz.html bug 50002 (author: abarth@webkit.org)
454 The commit-queue is continuing to process your patch.
455 --- End comment ---
456
457 """
458         test_names = ["foo/bar.html", "bar/baz.html"]
459         test_results = [self._mock_test_result(name) for name in test_names]
460
461         class MockZipFile(object):
462             def __init__(self):
463                 self.fp = StringIO()
464
465             def read(self, path):
466                 return ""
467
468             def namelist(self):
469                 # This is intentionally missing one diffs.txt to exercise the "upload the whole zip" codepath.
470                 return ['foo/bar-diffs.txt']
471
472         OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results, MockZipFile()], expected_logs=expected_logs)
473
474     def test_did_pass_testing_ews(self):
475         tool = MockTool()
476         patch = tool.bugs.fetch_attachment(10000)
477         queue = TestCommitQueue(tool)
478         self.assertFalse(queue.did_pass_testing_ews(patch))
479
480
481 class StyleQueueTest(QueuesTest):
482     def test_style_queue_with_style_exception(self):
483         expected_logs = {
484             "begin_work_queue": self._default_begin_work_queue_logs("style-queue"),
485             "process_work_item": """Running: webkit-patch --status-host=example.com clean
486 MOCK: update_status: style-queue Cleaned working directory
487 Running: webkit-patch --status-host=example.com update
488 MOCK: update_status: style-queue Updated working directory
489 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000
490 MOCK: update_status: style-queue Applied patch
491 Running: webkit-patch --status-host=example.com apply-watchlist-local 50000
492 MOCK: update_status: style-queue Watchlist applied
493 Running: webkit-patch --status-host=example.com check-style-local --non-interactive --quiet
494 MOCK: update_status: style-queue Style checked
495 MOCK: update_status: style-queue Pass
496 MOCK: release_work_item: style-queue 10000
497 """,
498             "handle_unexpected_error": "Mock error message\n",
499             "handle_script_error": "MOCK output\n",
500         }
501         tool = MockTool(executive_throws_when_run=set(['check-style']))
502         self.assert_queue_outputs(StyleQueue(), expected_logs=expected_logs, tool=tool)
503
504     def test_style_queue_with_watch_list_exception(self):
505         expected_logs = {
506             "begin_work_queue": self._default_begin_work_queue_logs("style-queue"),
507             "process_work_item": """Running: webkit-patch --status-host=example.com clean
508 MOCK: update_status: style-queue Cleaned working directory
509 Running: webkit-patch --status-host=example.com update
510 MOCK: update_status: style-queue Updated working directory
511 Running: webkit-patch --status-host=example.com apply-attachment --no-update --non-interactive 10000
512 MOCK: update_status: style-queue Applied patch
513 Running: webkit-patch --status-host=example.com apply-watchlist-local 50000
514 Exception for ['echo', '--status-host=example.com', 'apply-watchlist-local', 50000]
515
516 MOCK command output
517 MOCK: update_status: style-queue Unabled to apply watchlist
518 Running: webkit-patch --status-host=example.com check-style-local --non-interactive --quiet
519 MOCK: update_status: style-queue Style checked
520 MOCK: update_status: style-queue Pass
521 MOCK: release_work_item: style-queue 10000
522 """,
523             "handle_unexpected_error": "Mock error message\n",
524             "handle_script_error": "MOCK output\n",
525         }
526         tool = MockTool(executive_throws_when_run=set(['apply-watchlist-local']))
527         self.assert_queue_outputs(StyleQueue(), expected_logs=expected_logs, tool=tool)