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 json | 5 import json |
6 import optparse | 6 import optparse |
7 | 7 |
8 from webkitpy.common.net.buildbot import Build | 8 from webkitpy.common.net.buildbot import Build |
9 from webkitpy.common.net.git_cl import GitCL | 9 from webkitpy.common.net.git_cl import GitCL |
10 from webkitpy.common.checkout.git_mock import MockGit | 10 from webkitpy.common.checkout.git_mock import MockGit |
11 from webkitpy.common.net.layout_test_results import LayoutTestResults | 11 from webkitpy.common.net.layout_test_results import LayoutTestResults |
12 from webkitpy.common.system.log_testing import LoggingTestCase | 12 from webkitpy.common.system.log_testing import LoggingTestCase |
13 from webkitpy.layout_tests.builder_list import BuilderList | 13 from webkitpy.layout_tests.builder_list import BuilderList |
| 14 from webkitpy.tool.commands.rebaseline import TestBaselineSet |
14 from webkitpy.tool.commands.rebaseline_cl import RebaselineCL | 15 from webkitpy.tool.commands.rebaseline_cl import RebaselineCL |
15 from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase | 16 from webkitpy.tool.commands.rebaseline_unittest import BaseTestCase |
16 | 17 |
17 | 18 |
18 class RebaselineCLTest(BaseTestCase, LoggingTestCase): | 19 class RebaselineCLTest(BaseTestCase, LoggingTestCase): |
19 command_constructor = RebaselineCL | 20 command_constructor = RebaselineCL |
20 | 21 |
21 def setUp(self): | 22 def setUp(self): |
22 BaseTestCase.setUp(self) | 23 BaseTestCase.setUp(self) |
23 LoggingTestCase.setUp(self) | 24 LoggingTestCase.setUp(self) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 'fast/dom/prototype-taco.html', | 122 'fast/dom/prototype-taco.html', |
122 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation
-attr.html', | 123 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation
-attr.html', |
123 ], | 124 ], |
124 'ignored': [], | 125 'ignored': [], |
125 })) | 126 })) |
126 | 127 |
127 # Write to the mock filesystem so that these tests are considered to exi
st. | 128 # Write to the mock filesystem so that these tests are considered to exi
st. |
128 tests = [ | 129 tests = [ |
129 'fast/dom/prototype-taco.html', | 130 'fast/dom/prototype-taco.html', |
130 'fast/dom/prototype-inheritance.html', | 131 'fast/dom/prototype-inheritance.html', |
| 132 'fast/dom/prototype-slowtest.html', |
131 'fast/dom/prototype-newtest.html', | 133 'fast/dom/prototype-newtest.html', |
132 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.ht
ml', | 134 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.ht
ml', |
133 ] | 135 ] |
134 for test in tests: | 136 for test in tests: |
135 self._write(self.mac_port.host.filesystem.join(self.mac_port.layout_
tests_dir(), test), 'contents') | 137 self._write(self.mac_port.host.filesystem.join(self.mac_port.layout_
tests_dir(), test), 'contents') |
136 | 138 |
137 def tearDown(self): | 139 def tearDown(self): |
138 BaseTestCase.tearDown(self) | 140 BaseTestCase.tearDown(self) |
139 LoggingTestCase.tearDown(self) | 141 LoggingTestCase.tearDown(self) |
140 | 142 |
141 @staticmethod | 143 @staticmethod |
142 def command_options(**kwargs): | 144 def command_options(**kwargs): |
143 options = { | 145 options = { |
144 'only_changed_tests': False, | 146 'only_changed_tests': False, |
145 'dry_run': False, | 147 'dry_run': False, |
146 'optimize': True, | 148 'optimize': True, |
147 'results_directory': None, | 149 'results_directory': None, |
148 'verbose': False, | 150 'verbose': False, |
149 'trigger_jobs': False, | 151 'trigger_jobs': False, |
150 } | 152 } |
151 options.update(kwargs) | 153 options.update(kwargs) |
152 return optparse.Values(dict(**options)) | 154 return optparse.Values(dict(**options)) |
153 | 155 |
154 def test_execute_with_issue_number_given(self): | 156 def test_execute_basic(self): |
155 return_code = self.command.execute(self.command_options(), [], self.tool
) | 157 return_code = self.command.execute(self.command_options(), [], self.tool
) |
156 self.assertEqual(return_code, 0) | 158 self.assertEqual(return_code, 0) |
157 self.assertLog([ | 159 self.assertLog([ |
158 'INFO: Rebaselining fast/dom/prototype-inheritance.html\n', | 160 'INFO: Rebaselining fast/dom/prototype-inheritance.html\n', |
159 'INFO: Rebaselining fast/dom/prototype-newtest.html\n', | 161 'INFO: Rebaselining fast/dom/prototype-newtest.html\n', |
160 'INFO: Rebaselining fast/dom/prototype-slowtest.html\n', | 162 'INFO: Rebaselining fast/dom/prototype-slowtest.html\n', |
161 'INFO: Rebaselining fast/dom/prototype-taco.html\n', | 163 'INFO: Rebaselining fast/dom/prototype-taco.html\n', |
162 'INFO: Rebaselining svg/dynamic-updates/SVGFEDropShadowElement-dom-s
tdDeviation-attr.html\n', | 164 'INFO: Rebaselining svg/dynamic-updates/SVGFEDropShadowElement-dom-s
tdDeviation-attr.html\n', |
163 ]) | 165 ]) |
164 | 166 |
165 def test_execute_with_no_issue_number(self): | 167 def test_execute_with_no_issue_number(self): |
166 git_cl = GitCL(self.tool) | 168 git_cl = GitCL(self.tool) |
167 git_cl.get_issue_number = lambda: 'None' | 169 git_cl.get_issue_number = lambda: 'None' |
168 self.command.git_cl = lambda: git_cl | 170 self.command.git_cl = lambda: git_cl |
169 return_code = self.command.execute(self.command_options(), [], self.tool
) | 171 return_code = self.command.execute(self.command_options(), [], self.tool
) |
170 self.assertEqual(return_code, 1) | 172 self.assertEqual(return_code, 1) |
171 self.assertLog(['ERROR: No issue number for current branch.\n']) | 173 self.assertLog(['ERROR: No issue number for current branch.\n']) |
172 | 174 |
173 def test_execute_with_issue_number_from_branch(self): | |
174 return_code = self.command.execute(self.command_options(), [], self.tool
) | |
175 self.assertEqual(return_code, 0) | |
176 self.assertLog([ | |
177 'INFO: Rebaselining fast/dom/prototype-inheritance.html\n', | |
178 'INFO: Rebaselining fast/dom/prototype-newtest.html\n', | |
179 'INFO: Rebaselining fast/dom/prototype-slowtest.html\n', | |
180 'INFO: Rebaselining fast/dom/prototype-taco.html\n', | |
181 'INFO: Rebaselining svg/dynamic-updates/SVGFEDropShadowElement-dom-s
tdDeviation-attr.html\n', | |
182 ]) | |
183 | |
184 def test_execute_with_only_changed_tests_option(self): | 175 def test_execute_with_only_changed_tests_option(self): |
185 return_code = self.command.execute(self.command_options(only_changed_tes
ts=True), [], self.tool) | 176 return_code = self.command.execute(self.command_options(only_changed_tes
ts=True), [], self.tool) |
186 self.assertEqual(return_code, 0) | 177 self.assertEqual(return_code, 0) |
187 # svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html | 178 # svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html |
188 # is in the list of failed tests, but not in the list of files modified | 179 # is in the list of failed tests, but not in the list of files modified |
189 # in the given CL; it should be included because all_tests is set to Tru
e. | 180 # in the given CL; it should be included because all_tests is set to Tru
e. |
190 self.assertLog([ | 181 self.assertLog([ |
191 'INFO: Rebaselining fast/dom/prototype-inheritance.html\n', | 182 'INFO: Rebaselining fast/dom/prototype-inheritance.html\n', |
192 'INFO: Rebaselining fast/dom/prototype-taco.html\n', | 183 'INFO: Rebaselining fast/dom/prototype-taco.html\n', |
193 ]) | 184 ]) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 ]) | 257 ]) |
267 | 258 |
268 def test_rebaseline_calls(self): | 259 def test_rebaseline_calls(self): |
269 """Tests the list of commands that are invoked when rebaseline is called
.""" | 260 """Tests the list of commands that are invoked when rebaseline is called
.""" |
270 # First write test contents to the mock filesystem so that | 261 # First write test contents to the mock filesystem so that |
271 # fast/dom/prototype-taco.html is considered a real test to rebaseline. | 262 # fast/dom/prototype-taco.html is considered a real test to rebaseline. |
272 port = self.tool.port_factory.get('test-win-win7') | 263 port = self.tool.port_factory.get('test-win-win7') |
273 self._write( | 264 self._write( |
274 port.host.filesystem.join(port.layout_tests_dir(), 'fast/dom/prototy
pe-taco.html'), | 265 port.host.filesystem.join(port.layout_tests_dir(), 'fast/dom/prototy
pe-taco.html'), |
275 'test contents') | 266 'test contents') |
| 267 test_baseline_set = TestBaselineSet(self.tool) |
| 268 test_baseline_set.add('fast/dom/prototype-taco.html', Build('MOCK Try Wi
n', 5000)) |
276 | 269 |
277 self.command.rebaseline( | 270 self.command.rebaseline(self.command_options(), test_baseline_set) |
278 self.command_options(), | |
279 {'fast/dom/prototype-taco.html': [Build('MOCK Try Win', 5000)]}) | |
280 | 271 |
281 self.assertEqual( | 272 self.assertEqual( |
282 self.tool.executive.calls, | 273 self.tool.executive.calls, |
283 [ | 274 [ |
284 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt', | 275 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt', |
285 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html']], | 276 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html']], |
286 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt', | 277 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt', |
287 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html', '--build-number', '5000']], | 278 '--builder', 'MOCK Try Win', '--test', 'fast/dom/prototype-tac
o.html', '--build-number', '5000']], |
288 [['python', 'echo', 'optimize-baselines', '--suffixes', 'txt', '
fast/dom/prototype-taco.html']] | 279 [['python', 'echo', 'optimize-baselines', '--suffixes', 'txt', '
fast/dom/prototype-taco.html']] |
289 ]) | 280 ]) |
(...skipping 30 matching lines...) Expand all Loading... |
320 | 311 |
321 def test_bails_when_there_are_unstaged_baselines(self): | 312 def test_bails_when_there_are_unstaged_baselines(self): |
322 git = self.tool.git() | 313 git = self.tool.git() |
323 git.unstaged_changes = lambda: {'third_party/WebKit/LayoutTests/my-test-
expected.txt': '?'} | 314 git.unstaged_changes = lambda: {'third_party/WebKit/LayoutTests/my-test-
expected.txt': '?'} |
324 return_code = self.command.execute(self.command_options(), [], self.tool
) | 315 return_code = self.command.execute(self.command_options(), [], self.tool
) |
325 self.assertEqual(return_code, 1) | 316 self.assertEqual(return_code, 1) |
326 self.assertLog([ | 317 self.assertLog([ |
327 'ERROR: Aborting: there are unstaged baselines:\n', | 318 'ERROR: Aborting: there are unstaged baselines:\n', |
328 'ERROR: /mock-checkout/third_party/WebKit/LayoutTests/my-test-expe
cted.txt\n', | 319 'ERROR: /mock-checkout/third_party/WebKit/LayoutTests/my-test-expe
cted.txt\n', |
329 ]) | 320 ]) |
OLD | NEW |