OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import optparse | 5 import optparse |
6 import json | 6 import json |
7 | 7 |
8 from webkitpy.common.net.buildbot import Build | 8 from webkitpy.common.net.buildbot import Build |
9 from webkitpy.common.net.rietveld import Rietveld | 9 from webkitpy.common.net.rietveld import Rietveld |
10 from webkitpy.common.net.web_mock import MockWeb | 10 from webkitpy.common.net.web_mock import MockWeb |
11 from webkitpy.common.net.git_cl import GitCL | 11 from webkitpy.common.net.git_cl import GitCL |
12 from webkitpy.common.system.executive_mock import MockExecutive2 | 12 from webkitpy.common.system.executive_mock import MockExecutive2 |
13 from webkitpy.common.system.outputcapture import OutputCapture | 13 from webkitpy.common.system.outputcapture import OutputCapture |
14 from webkitpy.layout_tests.builder_list import BuilderList | 14 from webkitpy.layout_tests.builder_list import BuilderList |
15 from webkitpy.tool.commands.rebaseline_cl import RebaselineCL | 15 from webkitpy.tool.commands.rebaseline_cl import RebaselineCL |
16 from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase | 16 from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase |
17 | 17 |
18 | 18 |
| 19 # TODO(qyearsley): Change this to use webkitpy.common.system.logtesting.LoggingT
estCase instead of using OutputCapture. |
19 class RebaselineCLTest(BaseTestCase): | 20 class RebaselineCLTest(BaseTestCase): |
20 command_constructor = RebaselineCL | 21 command_constructor = RebaselineCL |
21 | 22 |
22 def setUp(self): | 23 def setUp(self): |
23 super(RebaselineCLTest, self).setUp() | 24 super(RebaselineCLTest, self).setUp() |
24 web = MockWeb(urls={ | 25 web = MockWeb(urls={ |
25 'https://codereview.chromium.org/api/11112222': json.dumps({ | 26 'https://codereview.chromium.org/api/11112222': json.dumps({ |
26 'patchsets': [1, 2], | 27 'patchsets': [1, 2], |
27 }), | 28 }), |
28 'https://codereview.chromium.org/api/11112222/2': json.dumps({ | 29 'https://codereview.chromium.org/api/11112222/2': json.dumps({ |
(...skipping 20 matching lines...) Expand all Loading... |
49 "is_try_builder": True, | 50 "is_try_builder": True, |
50 }, | 51 }, |
51 "MOCK Try Linux": { | 52 "MOCK Try Linux": { |
52 "port_name": "test-mac-mac10.10", | 53 "port_name": "test-mac-mac10.10", |
53 "specifiers": ["Mac10.10", "Release"], | 54 "specifiers": ["Mac10.10", "Release"], |
54 "is_try_builder": True, | 55 "is_try_builder": True, |
55 }, | 56 }, |
56 }) | 57 }) |
57 self.command.rietveld = Rietveld(web) | 58 self.command.rietveld = Rietveld(web) |
58 | 59 |
| 60 # Write to the mock filesystem so that these tests are considered to exi
st. |
| 61 port = self.mac_port |
| 62 tests = [ |
| 63 'fast/dom/prototype-taco.html', |
| 64 'fast/dom/prototype-inheritance.html', |
| 65 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.ht
ml', |
| 66 ] |
| 67 for test in tests: |
| 68 # pylint: disable=protected-access |
| 69 self._write(port._filesystem.join(port.layout_tests_dir(), test), 'c
ontents') |
| 70 |
59 @staticmethod | 71 @staticmethod |
60 def command_options(**kwargs): | 72 def command_options(**kwargs): |
61 options = { | 73 options = { |
62 'only_changed_tests': False, | 74 'only_changed_tests': False, |
63 'dry_run': False, | 75 'dry_run': False, |
64 'issue': None, | 76 'issue': None, |
65 'optimize': True, | 77 'optimize': True, |
66 'results_directory': None, | 78 'results_directory': None, |
67 'verbose': False, | 79 'verbose': False, |
68 'trigger_jobs': False, | 80 'trigger_jobs': False, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 # is in the list of failed tests, but not in the list of files modified | 139 # is in the list of failed tests, but not in the list of files modified |
128 # in the given CL; it should be included because all_tests is set to Tru
e. | 140 # in the given CL; it should be included because all_tests is set to Tru
e. |
129 self.assertMultiLineEqual( | 141 self.assertMultiLineEqual( |
130 logs, | 142 logs, |
131 ('Tests to rebaseline:\n' | 143 ('Tests to rebaseline:\n' |
132 ' fast/dom/prototype-inheritance.html: MOCK Try Win (5000)\n' | 144 ' fast/dom/prototype-inheritance.html: MOCK Try Win (5000)\n' |
133 ' fast/dom/prototype-taco.html: MOCK Try Win (5000)\n' | 145 ' fast/dom/prototype-taco.html: MOCK Try Win (5000)\n' |
134 'Rebaselining fast/dom/prototype-inheritance.html\n' | 146 'Rebaselining fast/dom/prototype-inheritance.html\n' |
135 'Rebaselining fast/dom/prototype-taco.html\n')) | 147 'Rebaselining fast/dom/prototype-taco.html\n')) |
136 | 148 |
| 149 def test_execute_with_nonexistent_test(self): |
| 150 oc = OutputCapture() |
| 151 try: |
| 152 oc.capture_output() |
| 153 self.command.execute(self.command_options(issue=11112222), ['some/no
n/existent/test.html'], self.tool) |
| 154 finally: |
| 155 _, _, logs = oc.restore_output() |
| 156 self.assertMultiLineEqual( |
| 157 logs, |
| 158 '/test.checkout/LayoutTests/some/non/existent/test.html not found, r
emoving from list.\n' |
| 159 'No tests to rebaseline; exiting.\n') |
| 160 |
137 def test_execute_with_trigger_jobs_option(self): | 161 def test_execute_with_trigger_jobs_option(self): |
138 oc = OutputCapture() | 162 oc = OutputCapture() |
139 try: | 163 try: |
140 oc.capture_output() | 164 oc.capture_output() |
141 self.command.execute(self.command_options(issue=11112222, trigger_jo
bs=True), [], self.tool) | 165 self.command.execute(self.command_options(issue=11112222, trigger_jo
bs=True), [], self.tool) |
142 finally: | 166 finally: |
143 _, _, logs = oc.restore_output() | 167 _, _, logs = oc.restore_output() |
144 # A message is printed showing that some try jobs are triggered. | 168 # A message is printed showing that some try jobs are triggered. |
145 self.assertMultiLineEqual( | 169 self.assertMultiLineEqual( |
146 logs, | 170 logs, |
147 ('Triggering try jobs for:\n' | 171 ('Triggering try jobs for:\n' |
148 ' MOCK Try Linux\n' | 172 ' MOCK Try Linux\n' |
149 'Tests to rebaseline:\n' | 173 'Tests to rebaseline:\n' |
150 ' svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr
.html: MOCK Try Win (5000)\n' | 174 ' svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr
.html: MOCK Try Win (5000)\n' |
151 ' fast/dom/prototype-inheritance.html: MOCK Try Win (5000)\n' | 175 ' fast/dom/prototype-inheritance.html: MOCK Try Win (5000)\n' |
152 ' fast/dom/prototype-taco.html: MOCK Try Win (5000)\n' | 176 ' fast/dom/prototype-taco.html: MOCK Try Win (5000)\n' |
153 'Rebaselining fast/dom/prototype-inheritance.html\n' | 177 'Rebaselining fast/dom/prototype-inheritance.html\n' |
154 'Rebaselining fast/dom/prototype-taco.html\n' | 178 'Rebaselining fast/dom/prototype-taco.html\n' |
155 'Rebaselining svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDev
iation-attr.html\n')) | 179 'Rebaselining svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDev
iation-attr.html\n')) |
156 # The first executive call, before the rebaseline calls, is triggering t
ry jobs. | 180 # The first executive call, before the rebaseline calls, is triggering t
ry jobs. |
157 self.assertEqual( | 181 self.assertEqual(self.tool.executive.calls[0], ['git', 'cl', 'try', '-b'
, 'MOCK Try Linux']) |
158 self.tool.executive.calls, | |
159 [ | |
160 ['git', 'cl', 'try', '-b', 'MOCK Try Linux'], | |
161 [ | |
162 ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
'--suffixes', 'png', | |
163 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviatio
n-attr.html'], | |
164 ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
'--suffixes', 'txt', | |
165 'fast/dom/prototype-inheritance.html'], | |
166 ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
'--suffixes', 'txt', | |
167 'fast/dom/prototype-taco.html'] | |
168 ] | |
169 ]) | |
170 | 182 |
171 def test_rebaseline_calls(self): | 183 def test_rebaseline_calls(self): |
172 """Tests the list of commands that are invoked when rebaseline is called
.""" | 184 """Tests the list of commands that are invoked when rebaseline is called
.""" |
173 # First write test contents to the mock filesystem so that | 185 # First write test contents to the mock filesystem so that |
174 # fast/dom/prototype-taco.html is considered a real test to rebaseline. | 186 # fast/dom/prototype-taco.html is considered a real test to rebaseline. |
175 # TODO(qyearsley): Change this to avoid accessing protected methods. | 187 # TODO(qyearsley): Change this to avoid accessing protected methods. |
176 # pylint: disable=protected-access | 188 # pylint: disable=protected-access |
177 port = self.tool.port_factory.get('test-win-win7') | 189 port = self.tool.port_factory.get('test-win-win7') |
178 self._write( | 190 self._write( |
179 port._filesystem.join(port.layout_tests_dir(), 'fast/dom/prototype-t
aco.html'), | 191 port._filesystem.join(port.layout_tests_dir(), 'fast/dom/prototype-t
aco.html'), |
180 'test contents') | 192 'test contents') |
181 | 193 |
182 self.command._rebaseline( | 194 self.command._rebaseline( |
183 self.command_options(issue=11112222), | 195 self.command_options(issue=11112222), |
184 {"fast/dom/prototype-taco.html": {Build("MOCK Try Win", 5000): ["txt
", "png"]}}) | 196 {"fast/dom/prototype-taco.html": {Build("MOCK Try Win", 5000): ["txt
", "png"]}}) |
185 | 197 |
186 self.assertEqual( | 198 self.assertEqual( |
187 self.tool.executive.calls, | 199 self.tool.executive.calls, |
188 [ | 200 [ |
189 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt', | 201 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt', |
190 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html', '--build-number', '5000']], | 202 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html', '--build-number', '5000']], |
191 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt', | 203 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt', |
192 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html', '--build-number', '5000']], | 204 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html', '--build-number', '5000']], |
193 [['python', 'echo', 'optimize-baselines', '--no-modify-scm', '--
suffixes', 'txt', 'fast/dom/prototype-taco.html']] | 205 [['python', 'echo', 'optimize-baselines', '--no-modify-scm', '--
suffixes', 'txt', 'fast/dom/prototype-taco.html']] |
194 ]) | 206 ]) |
OLD | NEW |