618d29113538c9ef8afa8c433f0279b1d609d39d
[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_and_throw_if_fail.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_stderr = {
134             "begin_work_queue": self._default_begin_work_queue_stderr("feeder-queue"),
135             "next_work_item": "",
136             "process_work_item": """Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
137 Warning, attachment 10001 on bug 50000 has invalid committer (non-committer@example.com)
138 MOCK setting flag 'commit-queue' to '-' on attachment '10001' with comment 'Rejecting attachment 10001 from commit-queue.' and additional comment 'non-committer@example.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/committers.py.
139
140 - If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.
141
142 - If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/committers.py 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.'
143 MOCK: update_work_items: commit-queue [10005, 10000]
144 MOCK: submit_to_ews: 10002
145 """,
146         }
147         expected_logs = {
148             "process_work_item": """Feeding commit-queue items [10005, 10000]
149 Feeding EWS (1 r? patch, 1 new)
150 """,
151             "handle_unexpected_error": "Mock error message\n",
152         }
153         self.assert_queue_outputs(queue, tool=tool, expected_stderr=expected_stderr, expected_logs=expected_logs)
154
155
156 class AbstractPatchQueueTest(CommandsTest):
157     def test_next_patch(self):
158         queue = AbstractPatchQueue()
159         tool = MockTool()
160         queue.bind_to_tool(tool)
161         queue._options = Mock()
162         queue._options.port = None
163         self.assertEqual(queue._next_patch(), None)
164         tool.status_server = MockStatusServer(work_items=[2, 10000, 10001])
165         expected_stdout = "MOCK: fetch_attachment: 2 is not a known attachment id\n"  # A mock-only message to prevent us from making mistakes.
166         expected_stderr = "MOCK: release_work_item: None 2\n"
167         patch = OutputCapture().assert_outputs(self, queue._next_patch, expected_stdout=expected_stdout, expected_stderr=expected_stderr)
168         # The patch.id() == 2 is ignored because it doesn't exist.
169         self.assertEqual(patch.id(), 10000)
170         self.assertEqual(queue._next_patch().id(), 10001)
171         self.assertEqual(queue._next_patch(), None)    # When the queue is empty
172
173     def test_upload_results_archive_for_patch(self):
174         queue = AbstractPatchQueue()
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_stderr = """MOCK add_attachment_to_bug: bug_id=50000, description=Archive of layout-test-results from bot 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: MockPort  Platform: MockPlatform 1.0
185 -- End comment --
186 """
187         OutputCapture().assert_outputs(self, queue._upload_results_archive_for_patch, [patch, Mock()], expected_stderr=expected_stderr)
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_stderr = {
242             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
243             "next_work_item": "",
244             "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
245 MOCK: update_status: commit-queue Updated working directory
246 MOCK: update_status: commit-queue Applied patch
247 MOCK: update_status: commit-queue ChangeLog validated
248 MOCK: update_status: commit-queue Built patch
249 MOCK: update_status: commit-queue Passed tests
250 MOCK: update_status: commit-queue Landed patch
251 MOCK: update_status: commit-queue Pass
252 MOCK: release_work_item: commit-queue 10000
253 """,
254             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.' and additional comment 'Mock error message'\n",
255         }
256         expected_logs = {
257             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
258         }
259         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_stderr=expected_stderr, expected_logs=expected_logs)
260
261     def test_commit_queue_failure(self):
262         expected_stderr = {
263             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
264             "next_work_item": "",
265             "process_work_item": """MOCK: update_status: commit-queue Cleaned working directory
266 MOCK: update_status: commit-queue Updated working directory
267 MOCK: update_status: commit-queue Patch does not apply
268 MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.' and additional comment 'MOCK script error
269 Full output: http://dummy_url'
270 MOCK: update_status: commit-queue Fail
271 MOCK: release_work_item: commit-queue 10000
272 """,
273             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.' and additional comment 'Mock error message'\n",
274         }
275         expected_logs = {
276             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
277         }
278         queue = CommitQueue()
279
280         def mock_run_webkit_patch(command):
281             if command[0] == 'clean' or command[0] == 'update':
282                 # We want cleaning to succeed so we can error out on a step
283                 # that causes the commit-queue to reject the patch.
284                 return
285             raise ScriptError('MOCK script error')
286
287         queue.run_webkit_patch = mock_run_webkit_patch
288         self.assert_queue_outputs(queue, expected_stderr=expected_stderr, expected_logs=expected_logs)
289
290     def test_commit_queue_failure_with_failing_tests(self):
291         expected_stderr = {
292             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
293             "next_work_item": "",
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.' and additional comment 'New failing tests:
298 mock_test_name.html
299 another_test_name.html
300 Full output: http://dummy_url'
301 MOCK: update_status: commit-queue Fail
302 MOCK: release_work_item: commit-queue 10000
303 """,
304             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.' and additional comment 'Mock error message'\n",
305         }
306         expected_logs = {
307             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
308         }
309         queue = CommitQueue()
310
311         def mock_run_webkit_patch(command):
312             if command[0] == 'clean' or command[0] == 'update':
313                 # We want cleaning to succeed so we can error out on a step
314                 # that causes the commit-queue to reject the patch.
315                 return
316             queue._expected_failures.unexpected_failures_observed = lambda results: ["mock_test_name.html", "another_test_name.html"]
317             raise ScriptError('MOCK script error')
318
319         queue.run_webkit_patch = mock_run_webkit_patch
320         self.assert_queue_outputs(queue, expected_stderr=expected_stderr, expected_logs=expected_logs)
321
322     def test_rollout(self):
323         tool = MockTool(log_executive=True)
324         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.
325         tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
326         tool.buildbot.light_tree_on_fire()
327         expected_stderr = {
328             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
329             "next_work_item": "",
330             "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean', '--port=%(port_name)s'], cwd=/mock-checkout
331 MOCK: update_status: commit-queue Cleaned working directory
332 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update', '--port=%(port_name)s'], cwd=/mock-checkout
333 MOCK: update_status: commit-queue Updated working directory
334 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 10000, '--port=%(port_name)s'], cwd=/mock-checkout
335 MOCK: update_status: commit-queue Applied patch
336 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'validate-changelog', '--non-interactive', 10000, '--port=%(port_name)s'], cwd=/mock-checkout
337 MOCK: update_status: commit-queue ChangeLog validated
338 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'build', '--no-clean', '--no-update', '--build-style=release', '--port=%(port_name)s'], cwd=/mock-checkout
339 MOCK: update_status: commit-queue Built patch
340 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive', '--port=%(port_name)s'], cwd=/mock-checkout
341 MOCK: update_status: commit-queue Passed tests
342 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 10000, '--port=%(port_name)s'], cwd=/mock-checkout
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_name": CommitQueue.port_name},
347             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10000' with comment 'Rejecting attachment 10000 from commit-queue.' and additional comment 'Mock error message'\n",
348         }
349         expected_logs = {
350             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
351         }
352         self.assert_queue_outputs(CommitQueue(), tool=tool, expected_stderr=expected_stderr, expected_logs=expected_logs)
353
354     def test_rollout_lands(self):
355         tool = MockTool(log_executive=True)
356         tool.buildbot.light_tree_on_fire()
357         rollout_patch = tool.bugs.fetch_attachment(10005)  # _patch6, a rollout patch.
358         assert(rollout_patch.is_rollout())
359         expected_stderr = {
360             "begin_work_queue": self._default_begin_work_queue_stderr("commit-queue"),
361             "next_work_item": "",
362             "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean', '--port=%(port_name)s'], cwd=/mock-checkout
363 MOCK: update_status: commit-queue Cleaned working directory
364 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update', '--port=%(port_name)s'], cwd=/mock-checkout
365 MOCK: update_status: commit-queue Updated working directory
366 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 10005, '--port=%(port_name)s'], cwd=/mock-checkout
367 MOCK: update_status: commit-queue Applied patch
368 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'validate-changelog', '--non-interactive', 10005, '--port=%(port_name)s'], cwd=/mock-checkout
369 MOCK: update_status: commit-queue ChangeLog validated
370 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 10005, '--port=%(port_name)s'], cwd=/mock-checkout
371 MOCK: update_status: commit-queue Landed patch
372 MOCK: update_status: commit-queue Pass
373 MOCK: release_work_item: commit-queue 10005
374 """ % {"port_name": CommitQueue.port_name},
375             "handle_unexpected_error": "MOCK setting flag 'commit-queue' to '-' on attachment '10005' with comment 'Rejecting attachment 10005 from commit-queue.' and additional comment 'Mock error message'\n",
376         }
377         expected_logs = {
378             "handle_script_error": "ScriptError error message\n\nMOCK output\n",
379         }
380         self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_stderr=expected_stderr, expected_logs=expected_logs)
381
382     def test_auto_retry(self):
383         queue = CommitQueue()
384         options = Mock()
385         options.parent_command = "commit-queue"
386         tool = AlwaysCommitQueueTool()
387         sequence = NeedsUpdateSequence(None)
388
389         expected_stderr = "MOCK: update_status: commit-queue Tests passed, but commit failed (checkout out of date).  Updating, then landing without building or re-running tests.\n"
390         expected_logs = "Commit failed because the checkout is out of date. Please update and try again.\n"
391         state = {'patch': None}
392         OutputCapture().assert_outputs(self, sequence.run_and_handle_errors, [tool, options, state], expected_exception=TryAgain, expected_stderr=expected_stderr, expected_logs=expected_logs)
393
394         self.assertEqual(options.update, True)
395         self.assertEqual(options.build, False)
396         self.assertEqual(options.test, False)
397
398     def test_manual_reject_during_processing(self):
399         queue = SecondThoughtsCommitQueue(MockTool())
400         queue.begin_work_queue()
401         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.
402         queue._tool.filesystem.write_text_file('/tmp/layout-test-results/webkit_unit_tests_output.xml', '')
403         queue._options = Mock()
404         queue._options.port = None
405         expected_stderr = """MOCK: update_status: commit-queue Cleaned working directory
406 MOCK: update_status: commit-queue Updated working directory
407 MOCK: update_status: commit-queue Applied patch
408 MOCK: update_status: commit-queue ChangeLog validated
409 MOCK: update_status: commit-queue Built patch
410 MOCK: update_status: commit-queue Passed tests
411 MOCK: update_status: commit-queue Retry
412 MOCK: release_work_item: commit-queue 10000
413 """
414         OutputCapture().assert_outputs(self, queue.process_work_item, [QueuesTest.mock_work_item], expected_stderr=expected_stderr)
415
416     def test_report_flaky_tests(self):
417         queue = TestCommitQueue(MockTool())
418         expected_stderr = """MOCK bug comment: bug_id=50002, cc=None
419 --- Begin comment ---
420 The commit-queue just saw foo/bar.html flake (text diff) while processing attachment 10000 on bug 50000.
421 Port: MockPort  Platform: MockPlatform 1.0
422 --- End comment ---
423
424 MOCK add_attachment_to_bug: bug_id=50002, description=Failure diff from bot filename=failure.diff mimetype=None
425 MOCK bug comment: bug_id=50002, cc=None
426 --- Begin comment ---
427 The commit-queue just saw bar/baz.html flake (text diff) while processing attachment 10000 on bug 50000.
428 Port: MockPort  Platform: MockPlatform 1.0
429 --- End comment ---
430
431 MOCK add_attachment_to_bug: bug_id=50002, description=Archive of layout-test-results from bot filename=layout-test-results.zip mimetype=None
432 MOCK bug comment: bug_id=50000, cc=None
433 --- Begin comment ---
434 The commit-queue encountered the following flaky tests while processing attachment 10000:
435
436 foo/bar.html bug 50002 (author: abarth@webkit.org)
437 bar/baz.html bug 50002 (author: abarth@webkit.org)
438 The commit-queue is continuing to process your patch.
439 --- End comment ---
440
441 """
442         test_names = ["foo/bar.html", "bar/baz.html"]
443         test_results = [self._mock_test_result(name) for name in test_names]
444
445         class MockZipFile(object):
446             def __init__(self):
447                 self.fp = StringIO()
448
449             def read(self, path):
450                 return ""
451
452             def namelist(self):
453                 # This is intentionally missing one diffs.txt to exercise the "upload the whole zip" codepath.
454                 return ['foo/bar-diffs.txt']
455
456         OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results, MockZipFile()], expected_stderr=expected_stderr)
457
458     def test_did_pass_testing_ews(self):
459         tool = MockTool()
460         patch = tool.bugs.fetch_attachment(10000)
461         queue = TestCommitQueue(tool)
462         self.assertFalse(queue.did_pass_testing_ews(patch))
463
464
465 class StyleQueueTest(QueuesTest):
466     def test_style_queue_with_style_exception(self):
467         expected_stderr = {
468             "begin_work_queue": self._default_begin_work_queue_stderr("style-queue"),
469             "next_work_item": "",
470             "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean'], cwd=/mock-checkout
471 MOCK: update_status: style-queue Cleaned working directory
472 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update'], cwd=/mock-checkout
473 MOCK: update_status: style-queue Updated working directory
474 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 10000], cwd=/mock-checkout
475 MOCK: update_status: style-queue Applied patch
476 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-watchlist-local', 50000], cwd=/mock-checkout
477 MOCK: update_status: style-queue Watchlist applied
478 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'check-style-local', '--non-interactive', '--quiet'], cwd=/mock-checkout
479 MOCK: update_status: style-queue Style checked
480 MOCK: update_status: style-queue Pass
481 MOCK: release_work_item: style-queue 10000
482 """,
483         }
484         expected_logs = {
485             "handle_unexpected_error": "Mock error message\n",
486             "handle_script_error": "MOCK output\n",
487         }
488         tool = MockTool(log_executive=True, executive_throws_when_run=set(['check-style']))
489         self.assert_queue_outputs(StyleQueue(), expected_stderr=expected_stderr, expected_logs=expected_logs, tool=tool)
490
491     def test_style_queue_with_watch_list_exception(self):
492         expected_stderr = {
493             "begin_work_queue": self._default_begin_work_queue_stderr("style-queue"),
494             "next_work_item": "",
495             "process_work_item": """MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'clean'], cwd=/mock-checkout
496 MOCK: update_status: style-queue Cleaned working directory
497 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'update'], cwd=/mock-checkout
498 MOCK: update_status: style-queue Updated working directory
499 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-attachment', '--no-update', '--non-interactive', 10000], cwd=/mock-checkout
500 MOCK: update_status: style-queue Applied patch
501 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'apply-watchlist-local', 50000], cwd=/mock-checkout
502 MOCK: update_status: style-queue Unabled to apply watchlist
503 MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'check-style-local', '--non-interactive', '--quiet'], cwd=/mock-checkout
504 MOCK: update_status: style-queue Style checked
505 MOCK: update_status: style-queue Pass
506 MOCK: release_work_item: style-queue 10000
507 """,
508         }
509         expected_logs = {
510             "begin_work_queue": self._default_begin_work_queue_logs("style-queue"),
511             "handle_unexpected_error": "Mock error message\n",
512             "handle_script_error": "MOCK output\n",
513         }
514         tool = MockTool(log_executive=True, executive_throws_when_run=set(['apply-watchlist-local']))
515         self.assert_queue_outputs(StyleQueue(), expected_stderr=expected_stderr, expected_logs=expected_logs, tool=tool)