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 unittest | 6 import unittest |
7 | 7 |
8 from webkitpy.common.net.buildbot import Build | 8 from webkitpy.common.net.buildbot import Build |
9 from webkitpy.common.net.layouttestresults import LayoutTestResults | 9 from webkitpy.common.net.layouttestresults import LayoutTestResults |
10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 | 10 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 } | 102 } |
103 })) | 103 })) |
104 | 104 |
105 | 105 |
106 class TestCopyExistingBaselinesInternal(BaseTestCase): | 106 class TestCopyExistingBaselinesInternal(BaseTestCase): |
107 command_constructor = CopyExistingBaselinesInternal | 107 command_constructor = CopyExistingBaselinesInternal |
108 | 108 |
109 def setUp(self): | 109 def setUp(self): |
110 super(TestCopyExistingBaselinesInternal, self).setUp() | 110 super(TestCopyExistingBaselinesInternal, self).setUp() |
111 | 111 |
112 def test_copying_overwritten_baseline(self): | 112 def options(self, **kwargs): |
113 self.tool.executive = MockExecutive2() | 113 options_dict = { |
114 'results_directory': None, | |
115 'suffixes': 'txt', | |
116 'verbose': False, | |
117 } | |
118 options_dict.update(kwargs) | |
119 return optparse.Values(options_dict) | |
114 | 120 |
115 port = self.tool.port_factory.get('test-mac-mac10.10') | 121 def test_copy_baseline_mac(self): |
122 port = self.tool.port_factory.get('test-mac-mac10.11') | |
116 self._write( | 123 self._write( |
117 port._filesystem.join( | 124 port._filesystem.join( |
118 port.layout_tests_dir(), | 125 port.layout_tests_dir(), |
119 'platform/test-mac-mac10.10/failures/expected/image-expected.txt '), | 126 'platform/test-mac-mac10.11/failures/expected/image-expected.txt '), |
120 'original mac10.11 result') | 127 'original mac10.11 result') |
128 self.assertFalse(self.tool.filesystem.exists( | |
129 self.tool.filesystem.join( | |
130 port.layout_tests_dir(), | |
131 'platform/test-mac-mac10.10/failures/expected/image-expected.txt '))) | |
121 | 132 |
122 oc = OutputCapture() | 133 oc = OutputCapture() |
123 try: | 134 oc.capture_output() |
124 options = optparse.Values({ | 135 self.command.execute(self.options(builder='MOCK Mac10.11', test='failure s/expected/image.html'), [], self.tool) |
125 'builder': "MOCK Mac10.11", | 136 out, _, _ = oc.restore_output() |
126 'suffixes': 'txt', | |
127 'verbose': True, | |
128 'test': "failures/expected/image.html", | |
129 'results_directory': None | |
130 }) | |
131 oc.capture_output() | |
132 self.command.execute(options, [], self.tool) | |
133 finally: | |
134 out, _, _ = oc.restore_output() | |
135 | 137 |
136 self.assertMultiLineEqual( | 138 # The Mac 10.11 baseline is copied over to the Mac 10.10 directory, |
139 # because Mac10.10 is the "immediate predecessor" in the fallback tree. | |
140 # That means that normally for Mac10.10 if there's no Mac10.10-specific | |
141 # baseline, then we fall back to the Mac10.11 baseline. | |
142 # The idea is, if in the next step wae download new baselines for Mac10. 11 | |
wkorman
2016/10/06 21:22:29
wae -> we
qyearsley
2016/10/06 22:00:29
Done
| |
143 # but not Mac10.10, then mac10.10 will still have the correct baseline. | |
144 self.assertEqual( | |
145 self._read(self.tool.filesystem.join( | |
146 port.layout_tests_dir(), | |
147 'platform/test-mac-mac10.11/failures/expected/image-expected.txt ')), | |
148 'original mac10.11 result') | |
149 self.assertEqual( | |
137 self._read(self.tool.filesystem.join( | 150 self._read(self.tool.filesystem.join( |
138 port.layout_tests_dir(), | 151 port.layout_tests_dir(), |
139 'platform/test-mac-mac10.10/failures/expected/image-expected.txt ')), | 152 'platform/test-mac-mac10.10/failures/expected/image-expected.txt ')), |
140 'original mac10.11 result') | 153 'original mac10.11 result') |
141 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete" : []}\n') | 154 self.assertEqual(out, '{"add": [], "remove-lines": [], "delete": []}\n') |
142 | 155 |
143 def test_copying_overwritten_baseline_to_multiple_locations(self): | 156 def test_copy_baseline_win7_to_linux_trusty(self): |
144 self.tool.executive = MockExecutive2() | |
145 | |
146 port = self.tool.port_factory.get('test-win-win7') | 157 port = self.tool.port_factory.get('test-win-win7') |
147 self._write( | 158 self._write( |
148 port._filesystem.join(port.layout_tests_dir(), 'platform/test-win-wi n7/failures/expected/image-expected.txt'), | 159 self.tool.filesystem.join( |
160 port.layout_tests_dir(), | |
161 'platform/test-win-win7/failures/expected/image-expected.txt'), | |
149 'original win7 result') | 162 'original win7 result') |
163 self.assertFalse(self.tool.filesystem.exists( | |
164 self.tool.filesystem.join( | |
165 port.layout_tests_dir(), | |
166 'platform/test-linux-trusty/failures/expected/image-expected.txt '))) | |
150 | 167 |
151 oc = OutputCapture() | 168 oc = OutputCapture() |
152 try: | 169 oc.capture_output() |
153 options = optparse.Values({ | 170 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex pected/image.html'), [], self.tool) |
154 'builder': "MOCK Win7", | 171 out, _, _ = oc.restore_output() |
155 'suffixes': "txt", | |
156 'verbose': True, | |
157 'test': "failures/expected/image.html", | |
158 'results_directory': None | |
159 }) | |
160 oc.capture_output() | |
161 self.command.execute(options, [], self.tool) | |
162 finally: | |
163 out, _, _ = oc.restore_output() | |
164 | 172 |
165 self.assertMultiLineEqual( | 173 # The Mac Win7 baseline is copied over to the Linux Trusty directory, |
174 # because Linux Trusty is the baseline fallback "immediate predecessor" of Win7. | |
175 self.assertEqual( | |
176 self._read(self.tool.filesystem.join( | |
177 port.layout_tests_dir(), | |
178 'platform/test-win-win7/failures/expected/image-expected.txt')), | |
179 'original win7 result') | |
180 self.assertEqual( | |
166 self._read(self.tool.filesystem.join( | 181 self._read(self.tool.filesystem.join( |
167 port.layout_tests_dir(), | 182 port.layout_tests_dir(), |
168 'platform/test-linux-trusty/failures/expected/image-expected.txt ')), | 183 'platform/test-linux-trusty/failures/expected/image-expected.txt ')), |
169 'original win7 result') | 184 'original win7 result') |
170 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | 185 |
171 port.layout_tests_dir(), 'platform/test-linux-precise/userscripts/an other-test-expected.txt'))) | 186 self.assertEqual(out, '{"add": [], "remove-lines": [], "delete": []}\n') |
172 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
173 port.layout_tests_dir(), 'platform/test-mac-mac10.10/userscripts/ano ther-test-expected.txt'))) | |
174 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete" : []}\n') | |
175 | 187 |
176 def test_no_copy_existing_baseline(self): | 188 def test_no_copy_existing_baseline(self): |
177 self.tool.executive = MockExecutive2() | |
178 | |
179 port = self.tool.port_factory.get('test-win-win7') | 189 port = self.tool.port_factory.get('test-win-win7') |
180 self._write(port._filesystem.join(port.layout_tests_dir(), | 190 self._write( |
181 'platform/test-win-win7/failures/expec ted/image-expected.txt'), 'original win7 result') | 191 self.tool.filesystem.join( |
192 port.layout_tests_dir(), | |
193 'platform/test-win-win7/failures/expected/image-expected.txt'), | |
194 'original win7 result') | |
195 self._write( | |
196 self.tool.filesystem.join( | |
197 port.layout_tests_dir(), | |
198 'platform/test-linux-trusty/failures/expected/image-expected.txt '), | |
199 'original linux trusty result') | |
182 | 200 |
183 oc = OutputCapture() | 201 oc = OutputCapture() |
184 try: | 202 oc.capture_output() |
185 options = optparse.Values({ | 203 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex pected/image.html'), [], self.tool) |
186 'builder': "MOCK Win7", | 204 out, _, _ = oc.restore_output() |
187 'suffixes': "txt", | |
188 'verbose': True, | |
189 'test': "failures/expected/image.html", | |
190 'results_directory': None | |
191 }) | |
192 oc.capture_output() | |
193 self.command.execute(options, [], self.tool) | |
194 finally: | |
wkorman
2016/10/06 21:22:29
Just to make sure I understand the change, are we
qyearsley
2016/10/06 22:00:29
Right -- as far as I understand, if any sort of ex
wkorman
2016/10/06 22:29:28
Yes, thanks.
| |
195 out, _, _ = oc.restore_output() | |
196 | 205 |
197 self.assertMultiLineEqual( | 206 # Since a baseline existed already for Linux Trusty, the Win7 baseline i s not copied over. |
198 self._read(self.tool.filesystem.join( | 207 self.assertEqual( |
199 port.layout_tests_dir(), | |
200 'platform/test-linux-trusty/failures/expected/image-expected.txt ')), | |
201 'original win7 result') | |
202 self.assertMultiLineEqual( | |
203 self._read(self.tool.filesystem.join( | 208 self._read(self.tool.filesystem.join( |
204 port.layout_tests_dir(), | 209 port.layout_tests_dir(), |
205 'platform/test-win-win7/failures/expected/image-expected.txt')), | 210 'platform/test-win-win7/failures/expected/image-expected.txt')), |
206 'original win7 result') | 211 'original win7 result') |
207 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | 212 self.assertEqual( |
208 port.layout_tests_dir(), 'platform/test-mac-mac10.10/userscripts/ano ther-test-expected.txt'))) | 213 self._read(self.tool.filesystem.join( |
209 self.assertMultiLineEqual(out, '{"add": [], "remove-lines": [], "delete" : []}\n') | 214 port.layout_tests_dir(), |
215 'platform/test-linux-trusty/failures/expected/image-expected.txt ')), | |
216 'original linux trusty result') | |
217 | |
218 self.assertEqual(out, '{"add": [], "remove-lines": [], "delete": []}\n') | |
210 | 219 |
211 def test_no_copy_skipped_test(self): | 220 def test_no_copy_skipped_test(self): |
212 self.tool.executive = MockExecutive2() | |
213 port = self.tool.port_factory.get('test-win-win7') | 221 port = self.tool.port_factory.get('test-win-win7') |
214 fs = self.tool.filesystem | |
215 self._write( | 222 self._write( |
216 fs.join( | 223 self.tool.filesystem.join( |
217 port.layout_tests_dir(), | 224 port.layout_tests_dir(), |
218 'platform/test-win-win7/failures/expected/image-expected.txt'), | 225 'platform/test-win-win7/failures/expected/image-expected.txt'), |
219 'original win7 result') | 226 'original win7 result') |
220 expectations_path = fs.join(port.path_to_generic_test_expectations_file( )) | |
221 self._write( | 227 self._write( |
222 expectations_path, | 228 port.path_to_generic_test_expectations_file(), |
223 ("[ Win ] failures/expected/image.html [ Failure ]\n" | 229 ("[ Win ] failures/expected/image.html [ Failure ]\n" |
224 "[ Linux ] failures/expected/image.html [ Skip ]\n")) | 230 "[ Linux ] failures/expected/image.html [ Skip ]\n")) |
231 | |
225 oc = OutputCapture() | 232 oc = OutputCapture() |
226 try: | 233 oc.capture_output() |
227 options = optparse.Values({ | 234 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex pected/image.html'), [], self.tool) |
228 'builder': "MOCK Win7", | 235 oc.restore_output() |
229 'suffixes': "txt", 'verbose': True, | |
230 'test': "failures/expected/image.html", | |
231 'results_directory': None | |
232 }) | |
233 oc.capture_output() | |
234 self.command.execute(options, [], self.tool) | |
235 finally: | |
236 oc.restore_output() | |
237 | 236 |
237 # The Win7 baseline is not copied over to the Linux Trusty directory | |
238 # because the test is skipped on linux. | |
238 self.assertFalse( | 239 self.assertFalse( |
239 fs.exists(fs.join( | 240 self.tool.filesystem.exists(self.tool.filesystem.join( |
240 port.layout_tests_dir(), | |
241 'platform/test-mac-mac10.10/failures/expected/image-expected.txt '))) | |
242 self.assertFalse( | |
243 fs.exists(fs.join( | |
244 port.layout_tests_dir(), | 241 port.layout_tests_dir(), |
245 'platform/test-linux-trusty/failures/expected/image-expected.txt '))) | 242 'platform/test-linux-trusty/failures/expected/image-expected.txt '))) |
246 self.assertFalse( | |
247 fs.exists(fs.join( | |
248 port.layout_tests_dir(), | |
249 'platform/test-linux-precise/failures/expected/image-expected.tx t'))) | |
250 self.assertEqual( | |
251 self._read(fs.join(port.layout_tests_dir(), 'platform/test-win-win7/ failures/expected/image-expected.txt')), | |
252 'original win7 result') | |
253 | 243 |
254 | 244 |
255 class TestRebaselineTest(BaseTestCase): | 245 class TestRebaselineTest(BaseTestCase): |
256 command_constructor = RebaselineTest # AKA webkit-patch rebaseline-test-int ernal | 246 command_constructor = RebaselineTest # AKA webkit-patch rebaseline-test-int ernal |
257 | 247 |
258 def setUp(self): | 248 def setUp(self): |
259 super(TestRebaselineTest, self).setUp() | 249 super(TestRebaselineTest, self).setUp() |
260 | 250 |
261 @staticmethod | 251 @staticmethod |
262 def options(**kwargs): | 252 def options(**kwargs): |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 for cmd_line, cwd in commands: | 917 for cmd_line, cwd in commands: |
928 out = self.run_command(cmd_line, cwd=cwd) | 918 out = self.run_command(cmd_line, cwd=cwd) |
929 if 'rebaseline-test-internal' in cmd_line: | 919 if 'rebaseline-test-internal' in cmd_line: |
930 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "% s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6]) | 920 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "% s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6]) |
931 command_outputs.append([0, out, '']) | 921 command_outputs.append([0, out, '']) |
932 | 922 |
933 new_calls = self.calls[num_previous_calls:] | 923 new_calls = self.calls[num_previous_calls:] |
934 self.calls = self.calls[:num_previous_calls] | 924 self.calls = self.calls[:num_previous_calls] |
935 self.calls.append(new_calls) | 925 self.calls.append(new_calls) |
936 return command_outputs | 926 return command_outputs |
OLD | NEW |