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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_expectations_updater_unittest.py

Issue 2687093005: WPT importer: Use concise lists of version specifiers in expectation lines. (Closed)
Patch Set: Implement specifier simplification part Created 3 years, 10 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
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 json 5 import json
6 import copy 6 import copy
7 7
8 from webkitpy.common.host_mock import MockHost 8 from webkitpy.common.host_mock import MockHost
9 from webkitpy.common.net.buildbot import Build 9 from webkitpy.common.net.buildbot import Build
10 from webkitpy.common.net.buildbot_mock import MockBuildBot 10 from webkitpy.common.net.buildbot_mock import MockBuildBot
11 from webkitpy.common.net.layout_test_results import LayoutTestResult, LayoutTest Results 11 from webkitpy.common.net.layout_test_results import LayoutTestResult, LayoutTest Results
12 from webkitpy.common.net.web_mock import MockWeb 12 from webkitpy.common.net.web_mock import MockWeb
13 from webkitpy.common.system.log_testing import LoggingTestCase 13 from webkitpy.common.system.log_testing import LoggingTestCase
14 from webkitpy.layout_tests.builder_list import BuilderList 14 from webkitpy.layout_tests.builder_list import BuilderList
15 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER _COMMENT 15 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER _COMMENT
16 16
17 17
18 class WPTExpectationsUpdaterTest(LoggingTestCase): 18 class WPTExpectationsUpdaterTest(LoggingTestCase):
19 19
20 def mock_host(self): 20 def mock_host(self):
21 super(WPTExpectationsUpdaterTest, self).setUp() 21 super(WPTExpectationsUpdaterTest, self).setUp()
22 host = MockHost() 22 host = MockHost()
23 host.builders = BuilderList({ 23 host.builders = BuilderList({
24 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': [' Mac10.10', 'Release']}, 24 'MOCK Try Mac10.10': {
25 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': [' Mac10.11', 'Release']}, 25 'port_name': 'test-mac-mac10.10',
26 'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Tr usty', 'Release']}, 26 'specifiers': ['Mac10.10', 'Release'],
27 'MOCK Win10': {'port_name': 'test-win-win10', 'specifiers': ['Win10' , 'Release']}, 27 'is_try_builder': True,
28 'MOCK Win7': {'port_name': 'test-win-win7', 'specifiers': ['Win7', ' Release']}, 28 },
29 'MOCK Android': {'port_name': 'test-android', 'specifiers': ['Androi d', 'Release']}, 29 'MOCK Try Mac10.11': {
30 'port_name': 'test-mac-mac10.11',
31 'specifiers': ['Mac10.11', 'Release'],
32 'is_try_builder': True,
33 },
34 'MOCK Try Trusty': {
35 'port_name': 'test-linux-trusty',
36 'specifiers': ['Trusty', 'Release'],
37 'is_try_builder': True,
38 },
39 'MOCK Try Win10': {
40 'port_name': 'test-win-win10',
41 'specifiers': ['Win10', 'Release'],
42 'is_try_builder': True,
43 },
44 'MOCK Try Win7': {
45 'port_name': 'test-win-win7',
46 'specifiers': ['Win7', 'Release'],
47 'is_try_builder': True,
48 },
30 }) 49 })
31 return host 50 return host
32 51
33 def test_get_failing_results_dict_only_passing_results(self): 52 def test_get_failing_results_dict_only_passing_results(self):
34 host = self.mock_host() 53 host = self.mock_host()
35 host.buildbot.set_results(Build('MOCK Mac10.10', 123), LayoutTestResults ({ 54 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), LayoutTestRes ults({
36 'tests': { 55 'tests': {
37 'x': { 56 'x': {
38 'passing-test.html': { 57 'passing-test.html': {
39 'expected': 'PASS', 58 'expected': 'PASS',
40 'actual': 'PASS', 59 'actual': 'PASS',
41 }, 60 },
42 }, 61 },
43 }, 62 },
44 })) 63 }))
45 updater = WPTExpectationsUpdater(host) 64 updater = WPTExpectationsUpdater(host)
46 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Mac10.10', 123)), {}) 65 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Try Mac10. 10', 123)), {})
47 66
48 def test_get_failing_results_dict_no_results(self): 67 def test_get_failing_results_dict_no_results(self):
49 host = self.mock_host() 68 host = self.mock_host()
50 host.buildbot = MockBuildBot() 69 host.buildbot = MockBuildBot()
51 host.buildbot.set_results(Build('MOCK Mac10.10', 123), None) 70 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), None)
52 updater = WPTExpectationsUpdater(host) 71 updater = WPTExpectationsUpdater(host)
53 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Mac10.10', 123)), {}) 72 self.assertEqual(updater.get_failing_results_dict(Build('MOCK Try Mac10. 10', 123)), {})
54 73
55 def test_get_failing_results_dict_some_failing_results(self): 74 def test_get_failing_results_dict_some_failing_results(self):
56 host = self.mock_host() 75 host = self.mock_host()
57 host.buildbot.set_results(Build('MOCK Mac10.10', 123), LayoutTestResults ({ 76 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), LayoutTestRes ults({
58 'tests': { 77 'tests': {
59 'x': { 78 'x': {
60 'failing-test.html': { 79 'failing-test.html': {
61 'expected': 'PASS', 80 'expected': 'PASS',
62 'actual': 'IMAGE', 81 'actual': 'IMAGE',
63 'is_unexpected': True, 82 'is_unexpected': True,
64 }, 83 },
65 }, 84 },
66 }, 85 },
67 })) 86 }))
68 updater = WPTExpectationsUpdater(host) 87 updater = WPTExpectationsUpdater(host)
69 results_dict = updater.get_failing_results_dict(Build('MOCK Mac10.10', 1 23)) 88 results_dict = updater.get_failing_results_dict(Build('MOCK Try Mac10.10 ', 123))
70 self.assertEqual( 89 self.assertEqual(
71 results_dict, 90 results_dict,
72 { 91 {
73 'x/failing-test.html': { 92 'x/failing-test.html': {
74 'test-mac-mac10.10': { 93 'test-mac-mac10.10': {
75 'actual': 'IMAGE', 94 'actual': 'IMAGE',
76 'expected': 'PASS', 95 'expected': 'PASS',
77 'bug': 'crbug.com/626703', 96 'bug': 'crbug.com/626703',
78 }, 97 },
79 }, 98 },
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/ test'}, 147 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/ test'},
129 } 148 }
130 } 149 }
131 self.assertEqual(updater.create_line_list(results), []) 150 self.assertEqual(updater.create_line_list(results), [])
132 151
133 def test_create_line_list_new_tests(self): 152 def test_create_line_list_new_tests(self):
134 # In this example, there are unexpected non-fail results in w3c tests. 153 # In this example, there are unexpected non-fail results in w3c tests.
135 updater = WPTExpectationsUpdater(self.mock_host()) 154 updater = WPTExpectationsUpdater(self.mock_host())
136 results = { 155 results = {
137 'external/fake/test/path.html': { 156 'external/fake/test/path.html': {
138 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/ test'}, 157 'test-linux-trusty': {'expected': 'FAIL', 'actual': 'PASS', 'bug ': 'crbug.com/test'},
139 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c om/test'}, 158 'test-mac-mac10.10': {'expected': 'FAIL', 'actual': 'PASS', 'bug ': 'crbug.com/test'},
140 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co m/test'}, 159 'test-mac-mac10.11': {'expected': 'FAIL', 'actual': 'TIMEOUT', ' bug': 'crbug.com/test'},
141 } 160 }
142 } 161 }
143 self.assertEqual( 162 self.assertEqual(
144 updater.create_line_list(results), 163 updater.create_line_list(results),
145 [ 164 [
146 'crbug.com/test [ three ] external/fake/test/path.html [ Pass ]' , 165 'crbug.com/test [ Linux ] external/fake/test/path.html [ Pass ]' ,
147 'crbug.com/test [ two ] external/fake/test/path.html [ Timeout ] ', 166 'crbug.com/test [ Mac10.10 ] external/fake/test/path.html [ Pass ]',
148 'crbug.com/test [ one ] external/fake/test/path.html [ Pass ]', 167 'crbug.com/test [ Mac10.11 ] external/fake/test/path.html [ Time out ]',
149 ]) 168 ])
150 169
170 def test_specifier_part(self):
171 updater = WPTExpectationsUpdater(self.mock_host())
172 self.assertEqual(updater.specifier_part(['test-mac-mac10.10'], 'x/y.html '), '[ Mac10.10 ]')
173
174 def test_skipped_specifiers_when_test_is_wontfix(self):
175 host = self.mock_host()
176 expectations_path = '/test.checkout/LayoutTests/NeverFixTests'
177 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Trusty ] ext ernal/wpt/test.html [ WontFix ]\n'
178 host.filesystem.files['/test.checkout/LayoutTests/external/wpt/test.html '] = ''
179 updater = WPTExpectationsUpdater(host)
180 self.assertEqual(updater.skipped_specifiers('external/wpt/test.html'), [ 'Trusty'])
181
182 def test_simplify_specifiers(self):
183 macros = {
184 'mac': ['mac10.10', 'mac10.11'],
185 'win': ['win7', 'win10'],
186 'linux': ['trusty'],
187 }
188 updater = WPTExpectationsUpdater(self.mock_host())
189 self.assertEqual(updater.simplify_specifiers(['Mac10.10', 'Mac10.11'], m acros), ['Mac'])
190 self.assertEqual(updater.simplify_specifiers(['Mac10.10', 'Mac10.11', 'T rusty'], macros), ['Linux', 'Mac'])
191 self.assertEqual(updater.simplify_specifiers(['Mac10.10', 'Mac10.11', 'T rusty', 'Win7', 'Win10'], macros), [])
jeffcarp 2017/02/13 20:42:18 Can you also test the case when there are more ver
qyearsley 2017/02/14 00:00:51 A few points which are possibly confusing: The "
192
151 def test_merge_dicts_with_conflict_raise_exception(self): 193 def test_merge_dicts_with_conflict_raise_exception(self):
152 updater = WPTExpectationsUpdater(self.mock_host()) 194 updater = WPTExpectationsUpdater(self.mock_host())
153 # Both dicts here have the key "one", and the value is not equal. 195 # Both dicts here have the key "one", and the value is not equal.
154 with self.assertRaises(ValueError): 196 with self.assertRaises(ValueError):
155 updater.merge_dicts( 197 updater.merge_dicts(
156 { 198 {
157 'external/fake/test/path.html': { 199 'external/fake/test/path.html': {
158 'one': {'expected': 'FAIL', 'actual': 'PASS'}, 200 'one': {'expected': 'FAIL', 'actual': 'PASS'},
159 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, 201 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'},
160 'three': {'expected': 'FAIL', 'actual': 'PASS'}, 202 'three': {'expected': 'FAIL', 'actual': 'PASS'},
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 'bug': 'crbug.com/626703', 253 'bug': 'crbug.com/626703',
212 } 254 }
213 } 255 }
214 }) 256 })
215 257
216 def test_write_to_test_expectations_with_marker_comment(self): 258 def test_write_to_test_expectations_with_marker_comment(self):
217 host = self.mock_host() 259 host = self.mock_host()
218 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations' 260 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations'
219 host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n' 261 host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n'
220 updater = WPTExpectationsUpdater(host) 262 updater = WPTExpectationsUpdater(host)
221 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]'] 263 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]']
222 updater.write_to_test_expectations(line_list) 264 updater.write_to_test_expectations(line_list)
223 value = updater.host.filesystem.read_text_file(expectations_path) 265 value = updater.host.filesystem.read_text_file(expectations_path)
224 self.assertMultiLineEqual( 266 self.assertMultiLineEqual(
225 value, 267 value,
226 (MARKER_COMMENT + '\n' 268 (MARKER_COMMENT + '\n'
227 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) 269 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n'))
228 270
229 def test_write_to_test_expectations_with_no_marker_comment(self): 271 def test_write_to_test_expectations_with_no_marker_comment(self):
230 host = self.mock_host() 272 host = self.mock_host()
231 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations' 273 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations'
232 host.filesystem.files[expectations_path] = 'crbug.com/111 [ FakePlatform ]\n' 274 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Trusty ]\n'
233 updater = WPTExpectationsUpdater(host) 275 updater = WPTExpectationsUpdater(host)
234 line_list = ['crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]'] 276 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]']
235 updater.write_to_test_expectations(line_list) 277 updater.write_to_test_expectations(line_list)
236 value = host.filesystem.read_text_file(expectations_path) 278 value = host.filesystem.read_text_file(expectations_path)
237 self.assertMultiLineEqual( 279 self.assertMultiLineEqual(
238 value, 280 value,
239 ('crbug.com/111 [ FakePlatform ]\n' 281 ('crbug.com/111 [ Trusty ]\n'
240 '\n' + MARKER_COMMENT + '\n' 282 '\n' + MARKER_COMMENT + '\n'
241 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]')) 283 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'))
242 284
243 def test_write_to_test_expectations_skips_existing_lines(self): 285 def test_write_to_test_expectations_skips_existing_lines(self):
244 host = self.mock_host() 286 host = self.mock_host()
245 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations' 287 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations'
246 host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.h tml [ Failure ]\n' 288 host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.h tml [ Failure ]\n'
247 updater = WPTExpectationsUpdater(host) 289 updater = WPTExpectationsUpdater(host)
248 line_list = [ 290 line_list = [
249 'crbug.com/111 dont/copy/me.html [ Failure ]', 291 'crbug.com/111 dont/copy/me.html [ Failure ]',
250 'crbug.com/222 do/copy/me.html [ Failure ]' 292 'crbug.com/222 do/copy/me.html [ Failure ]'
251 ] 293 ]
252 updater.write_to_test_expectations(line_list) 294 updater.write_to_test_expectations(line_list)
253 value = host.filesystem.read_text_file(expectations_path) 295 value = host.filesystem.read_text_file(expectations_path)
254 self.assertEqual( 296 self.assertEqual(
255 value, 297 value,
256 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' 298 ('crbug.com/111 dont/copy/me.html [ Failure ]\n'
257 '\n' + MARKER_COMMENT + '\n' 299 '\n' + MARKER_COMMENT + '\n'
258 'crbug.com/222 do/copy/me.html [ Failure ]')) 300 'crbug.com/222 do/copy/me.html [ Failure ]'))
259 301
260 def test_write_to_test_expectations_with_marker_and_no_lines(self): 302 def test_write_to_test_expectations_with_marker_and_no_lines(self):
261 host = self.mock_host() 303 host = self.mock_host()
262 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations' 304 expectations_path = '/mock-checkout/third_party/WebKit/LayoutTests/TestE xpectations'
263 host.filesystem.files[expectations_path] = ( 305 host.filesystem.files[expectations_path] = (
264 MARKER_COMMENT + '\n' 306 MARKER_COMMENT + '\n'
265 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n') 307 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n')
266 updater = WPTExpectationsUpdater(host) 308 updater = WPTExpectationsUpdater(host)
267 updater.write_to_test_expectations([]) 309 updater.write_to_test_expectations([])
268 value = updater.host.filesystem.read_text_file(expectations_path) 310 value = updater.host.filesystem.read_text_file(expectations_path)
269 self.assertMultiLineEqual( 311 self.assertMultiLineEqual(
270 value, 312 value,
271 (MARKER_COMMENT + '\n' 313 (MARKER_COMMENT + '\n'
272 'crbug.com/123 [ FakePlatform ] fake/file/path.html [ Pass ]\n')) 314 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n'))
273 315
274 def test_is_js_test_true(self): 316 def test_is_js_test_true(self):
275 host = self.mock_host() 317 host = self.mock_host()
276 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo /bar.html'] = ( 318 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo /bar.html'] = (
277 '<script src="/resources/testharness.js"></script>') 319 '<script src="/resources/testharness.js"></script>')
278 updater = WPTExpectationsUpdater(host) 320 updater = WPTExpectationsUpdater(host)
279 self.assertTrue(updater.is_js_test('foo/bar.html')) 321 self.assertTrue(updater.is_js_test('foo/bar.html'))
280 322
281 def test_is_js_test_false(self): 323 def test_is_js_test_false(self):
282 host = self.mock_host() 324 host = self.mock_host()
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 updater.get_issue_number = lambda: '11112222' 434 updater.get_issue_number = lambda: '11112222'
393 updater.get_try_bots = lambda: ['test-builder-name'] 435 updater.get_try_bots = lambda: ['test-builder-name']
394 self.assertEqual(1, updater.run(args=[])) 436 self.assertEqual(1, updater.run(args=[]))
395 self.assertEqual( 437 self.assertEqual(
396 host.web.urls_fetched, 438 host.web.urls_fetched,
397 [ 439 [
398 'https://codereview.chromium.org/api/11112222', 440 'https://codereview.chromium.org/api/11112222',
399 'https://codereview.chromium.org/api/11112222/1' 441 'https://codereview.chromium.org/api/11112222/1'
400 ]) 442 ])
401 self.assertLog(['ERROR: No try job information was collected.\n']) 443 self.assertLog(['ERROR: No try job information was collected.\n'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698