Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

Issue 2721663003: Clarify the copy-existing-baselines-internal command. (Closed)
Patch Set: - Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.layout_test_results import LayoutTestResults 9 from webkitpy.common.net.layout_test_results import LayoutTestResults
10 from webkitpy.common.system.executive_mock import MockExecutive 10 from webkitpy.common.system.executive_mock import MockExecutive
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 def options(self, **kwargs): 111 def options(self, **kwargs):
112 options_dict = { 112 options_dict = {
113 'results_directory': None, 113 'results_directory': None,
114 'suffixes': 'txt', 114 'suffixes': 'txt',
115 'verbose': False, 115 'verbose': False,
116 } 116 }
117 options_dict.update(kwargs) 117 options_dict.update(kwargs)
118 return optparse.Values(options_dict) 118 return optparse.Values(options_dict)
119 119
120 def test_copy_baseline_mac(self): 120 def baseline_path(self, path_from_layout_test_dir):
121 port = self.tool.port_factory.get('test-mac-mac10.11') 121 port = self.tool.port_factory.get()
122 return self.tool.filesystem.join(port.layout_tests_dir(), path_from_layo ut_test_dir)
123
124 # The tests in this class all depend on the fall-back path graph
125 # that is set up in |TestPort.FALLBACK_PATHS|.
126
127 def test_copy_baseline_mac_newer_to_older_version(self):
128 # The test-mac-mac10.11 baseline is copied over to the test-mac-mac10.10
129 # baseline directory because test-mac-mac10.10 is the "immediate
130 # predecessor" in the fall-back graph.
122 self._write( 131 self._write(
123 port.host.filesystem.join( 132 self.baseline_path('platform/test-mac-mac10.11/failures/expected/ima ge-expected.txt'),
124 port.layout_tests_dir(), 133 'original test-mac-mac10.11 result')
125 'platform/test-mac-mac10.11/failures/expected/image-expected.txt '),
126 'original mac10.11 result')
127 self.assertFalse(self.tool.filesystem.exists( 134 self.assertFalse(self.tool.filesystem.exists(
128 self.tool.filesystem.join( 135 self.baseline_path('platform/test-mac-mac10.10/failures/expected/ima ge-expected.txt')))
129 port.layout_tests_dir(),
130 'platform/test-mac-mac10.10/failures/expected/image-expected.txt ')))
131 136
132 self.command.execute(self.options(builder='MOCK Mac10.11', test='failure s/expected/image.html'), [], self.tool) 137 self.command.execute(self.options(builder='MOCK Mac10.11', test='failure s/expected/image.html'), [], self.tool)
133 138
134 # The Mac 10.11 baseline is copied over to the Mac 10.10 directory,
135 # because Mac10.10 is the "immediate predecessor" in the fallback tree.
136 # That means that normally for Mac10.10 if there's no Mac10.10-specific
137 # baseline, then we fall back to the Mac10.11 baseline.
138 # The idea is, if in the next step we download new baselines for Mac10.1 1
139 # but not Mac10.10, then mac10.10 will still have the correct baseline.
140 self.assertEqual( 139 self.assertEqual(
141 self._read(self.tool.filesystem.join( 140 self._read(self.baseline_path('platform/test-mac-mac10.11/failures/e xpected/image-expected.txt')),
142 port.layout_tests_dir(), 141 'original test-mac-mac10.11 result')
143 'platform/test-mac-mac10.11/failures/expected/image-expected.txt ')),
144 'original mac10.11 result')
145 self.assertEqual( 142 self.assertEqual(
146 self._read(self.tool.filesystem.join( 143 self._read(self.baseline_path('platform/test-mac-mac10.10/failures/e xpected/image-expected.txt')),
147 port.layout_tests_dir(), 144 'original test-mac-mac10.11 result')
148 'platform/test-mac-mac10.10/failures/expected/image-expected.txt ')),
149 'original mac10.11 result')
150 145
151 def test_copying_overwritten_baseline_to_multiple_locations(self): 146 def test_copy_baseline_win10_to_linux_trusty_and_win7(self):
152 self.tool.executive = MockExecutive() 147 # The test-win-win10 baseline is copied over to the test-linux-trusty
148 # and test-win-win7 baseline paths, since both of these are "immediate
149 # predecessors".
150 self._write(
151 self.baseline_path('platform/test-win-win10/failures/expected/image- expected.txt'),
152 'original test-win-win10 result')
153 self.assertFalse(self.tool.filesystem.exists(
154 self.baseline_path('platform/test-linux-trusty/failures/expected/ima ge-expected.txt')))
153 155
154 def test_copy_baseline_win7_to_linux_trusty(self): 156 self.command.execute(self.options(builder='MOCK Win10', test='failures/e xpected/image.html'), [], self.tool)
155 port = self.tool.port_factory.get('test-win-win7')
156 self._write(
157 self.tool.filesystem.join(
158 port.layout_tests_dir(),
159 'platform/test-win-win7/failures/expected/image-expected.txt'),
160 'original win7 result')
161 self.assertFalse(self.tool.filesystem.exists(
162 self.tool.filesystem.join(
163 port.layout_tests_dir(),
164 'platform/test-linux-trusty/failures/expected/image-expected.txt ')))
165 157
166 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex pected/image.html'), [], self.tool)
167
168 # The Mac Win7 baseline is copied over to the Linux Trusty directory,
169 # because Linux Trusty is the baseline fallback "immediate predecessor" of Win7.
170 self.assertEqual( 158 self.assertEqual(
171 self._read(self.tool.filesystem.join( 159 self._read(self.baseline_path('platform/test-win-win10/failures/expe cted/image-expected.txt')),
172 port.layout_tests_dir(), 160 'original test-win-win10 result')
173 'platform/test-win-win7/failures/expected/image-expected.txt')),
174 'original win7 result')
175 self.assertEqual( 161 self.assertEqual(
176 self._read(self.tool.filesystem.join( 162 self._read(self.baseline_path('platform/test-linux-trusty/failures/e xpected/image-expected.txt')),
177 port.layout_tests_dir(), 163 'original test-win-win10 result')
178 'platform/test-linux-trusty/failures/expected/image-expected.txt ')), 164 self.assertEqual(
179 'original win7 result') 165 self._read(self.baseline_path('platform/test-linux-trusty/failures/e xpected/image-expected.txt')),
166 'original test-win-win10 result')
180 167
181 def test_no_copy_existing_baseline(self): 168 def test_no_copy_existing_baseline(self):
182 port = self.tool.port_factory.get('test-win-win7') 169 # If a baseline exists already for an "immediate prdecessor" baseline
170 # directory, (e.g. test-linux-trusty), then no "immediate successor"
171 # baselines (e.g. test-win-win10) are copied over.
183 self._write( 172 self._write(
184 self.tool.filesystem.join( 173 self.baseline_path('platform/test-win-win10/failures/expected/image- expected.txt'),
185 port.layout_tests_dir(), 174 'original test-win-win10 result')
186 'platform/test-win-win7/failures/expected/image-expected.txt'),
187 'original win7 result')
188 self._write( 175 self._write(
189 self.tool.filesystem.join( 176 self.baseline_path('platform/test-linux-trusty/failures/expected/ima ge-expected.txt'),
190 port.layout_tests_dir(), 177 'original test-linux-trusty result')
191 'platform/test-linux-trusty/failures/expected/image-expected.txt '),
192 'original linux trusty result')
193 178
194 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex pected/image.html'), [], self.tool) 179 self.command.execute(self.options(builder='MOCK Win10', test='failures/e xpected/image.html'), [], self.tool)
195 180
196 # Since a baseline existed already for Linux Trusty, the Win7 baseline i s not copied over.
197 self.assertEqual( 181 self.assertEqual(
198 self._read(self.tool.filesystem.join( 182 self._read(self.baseline_path('platform/test-win-win10/failures/expe cted/image-expected.txt')),
199 port.layout_tests_dir(), 183 'original test-win-win10 result')
200 'platform/test-win-win7/failures/expected/image-expected.txt')),
201 'original win7 result')
202 self.assertEqual( 184 self.assertEqual(
203 self._read(self.tool.filesystem.join( 185 self._read(self.baseline_path('platform/test-linux-trusty/failures/e xpected/image-expected.txt')),
204 port.layout_tests_dir(), 186 'original test-linux-trusty result')
205 'platform/test-linux-trusty/failures/expected/image-expected.txt ')),
206 'original linux trusty result')
207 187
208 def test_no_copy_skipped_test(self): 188 def test_no_copy_skipped_test(self):
209 port = self.tool.port_factory.get('test-win-win7') 189 # If a test is skipped on some platform, no baselines are copied over
190 # to that directory. In this example, the test is skipped on linux,
191 # so the test-win-win10 baseline is not copied over.
192 port = self.tool.port_factory.get('test-win-win10')
210 self._write( 193 self._write(
211 self.tool.filesystem.join( 194 self.baseline_path('platform/test-win-win10/failures/expected/image- expected.txt'),
212 port.layout_tests_dir(), 195 'original test-win-win10 result')
213 'platform/test-win-win7/failures/expected/image-expected.txt'),
214 'original win7 result')
215 self._write( 196 self._write(
216 port.path_to_generic_test_expectations_file(), 197 port.path_to_generic_test_expectations_file(),
217 ("[ Win ] failures/expected/image.html [ Failure ]\n" 198 ("[ Win ] failures/expected/image.html [ Failure ]\n"
218 "[ Linux ] failures/expected/image.html [ Skip ]\n")) 199 "[ Linux ] failures/expected/image.html [ Skip ]\n"))
219 200
220 self.command.execute(self.options(builder='MOCK Win7', test='failures/ex pected/image.html'), [], self.tool) 201 self.command.execute(self.options(builder='MOCK Win10', test='failures/e xpected/image.html'), [], self.tool)
221 202
222 # The Win7 baseline is not copied over to the Linux Trusty directory
223 # because the test is skipped on linux.
224 self.assertFalse( 203 self.assertFalse(
225 self.tool.filesystem.exists(self.tool.filesystem.join( 204 self.tool.filesystem.exists(self.baseline_path('platform/test-linux- trusty/failures/expected/image-expected.txt')))
226 port.layout_tests_dir(), 205
227 'platform/test-linux-trusty/failures/expected/image-expected.txt '))) 206 def test_port_for_primary_baseline(self):
207 self.assertEqual(self.command._port_for_primary_baseline('test-linux-tru sty').name(), 'test-linux-trusty')
208 self.assertEqual(self.command._port_for_primary_baseline('test-mac-mac10 .11').name(), 'test-mac-mac10.11')
209
210 def test_port_for_primary_baseline_not_found(self):
211 with self.assertRaises(Exception):
212 self.command._port_for_primary_baseline('test-foo-foo4.7')
228 213
229 214
230 class TestRebaselineTest(BaseTestCase): 215 class TestRebaselineTest(BaseTestCase):
231 command_constructor = RebaselineTest # AKA webkit-patch rebaseline-test-int ernal 216 command_constructor = RebaselineTest # AKA webkit-patch rebaseline-test-int ernal
232 217
233 def setUp(self): 218 def setUp(self):
234 super(TestRebaselineTest, self).setUp() 219 super(TestRebaselineTest, self).setUp()
235 220
236 @staticmethod 221 @staticmethod
237 def options(**kwargs): 222 def options(**kwargs):
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 for cmd_line, cwd in commands: 927 for cmd_line, cwd in commands:
943 out = self.run_command(cmd_line, cwd=cwd) 928 out = self.run_command(cmd_line, cwd=cwd)
944 if 'rebaseline-test-internal' in cmd_line: 929 if 'rebaseline-test-internal' in cmd_line:
945 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' % (cmd_line[8], cmd_line[6]) 930 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' % (cmd_line[8], cmd_line[6])
946 command_outputs.append([0, out, '']) 931 command_outputs.append([0, out, ''])
947 932
948 new_calls = self.calls[num_previous_calls:] 933 new_calls = self.calls[num_previous_calls:]
949 self.calls = self.calls[:num_previous_calls] 934 self.calls = self.calls[:num_previous_calls]
950 self.calls.append(new_calls) 935 self.calls.append(new_calls)
951 return command_outputs 936 return command_outputs
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698