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 copy | 5 import copy |
| 6 import json |
6 | 7 |
7 from webkitpy.common.host_mock import MockHost | 8 from webkitpy.common.host_mock import MockHost |
8 from webkitpy.common.net.buildbot import Build | 9 from webkitpy.common.net.buildbot import Build |
9 from webkitpy.common.net.buildbot_mock import MockBuildBot | 10 from webkitpy.common.net.buildbot_mock import MockBuildBot |
10 from webkitpy.common.net.layout_test_results import LayoutTestResult, LayoutTest
Results | 11 from webkitpy.common.net.layout_test_results import LayoutTestResult, LayoutTest
Results |
11 from webkitpy.common.system.log_testing import LoggingTestCase | 12 from webkitpy.common.system.log_testing import LoggingTestCase |
12 from webkitpy.layout_tests.builder_list import BuilderList | 13 from webkitpy.layout_tests.builder_list import BuilderList |
13 from webkitpy.layout_tests.port.factory_mock import MockPortFactory | 14 from webkitpy.layout_tests.port.factory_mock import MockPortFactory |
14 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER
_COMMENT | 15 from webkitpy.w3c.wpt_expectations_updater import WPTExpectationsUpdater, MARKER
_COMMENT |
15 | 16 |
(...skipping 29 matching lines...) Expand all Loading... |
45 'port_name': 'test-win-win10', | 46 'port_name': 'test-win-win10', |
46 'specifiers': ['Win10', 'Release'], | 47 'specifiers': ['Win10', 'Release'], |
47 'is_try_builder': True, | 48 'is_try_builder': True, |
48 }, | 49 }, |
49 'MOCK Try Win7': { | 50 'MOCK Try Win7': { |
50 'port_name': 'test-win-win7', | 51 'port_name': 'test-win-win7', |
51 'specifiers': ['Win7', 'Release'], | 52 'specifiers': ['Win7', 'Release'], |
52 'is_try_builder': True, | 53 'is_try_builder': True, |
53 }, | 54 }, |
54 }) | 55 }) |
| 56 |
| 57 host.filesystem.write_text_file( |
| 58 host.port_factory.get().layout_tests_dir() + '/external/wpt/MANIFEST
.json', |
| 59 json.dumps({ |
| 60 'items': { |
| 61 'reftest': { |
| 62 'reftest.html': [ |
| 63 ['/reftest.html', [['/reftest-ref.html', '==']], {}] |
| 64 ] |
| 65 }, |
| 66 'testharness': { |
| 67 'test/path.html': [['/test/path.html', {}]], |
| 68 'test/zzzz.html': [['/test/zzzz.html', {}]], |
| 69 }, |
| 70 'manual': { |
| 71 'x-manual.html': [['/x-manual.html', {}]], |
| 72 }, |
| 73 }, |
| 74 })) |
| 75 |
55 return host | 76 return host |
56 | 77 |
57 def test_get_failing_results_dict_only_passing_results(self): | 78 def test_get_failing_results_dict_only_passing_results(self): |
58 host = self.mock_host() | 79 host = self.mock_host() |
59 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), LayoutTestRes
ults({ | 80 host.buildbot.set_results(Build('MOCK Try Mac10.10', 123), LayoutTestRes
ults({ |
60 'tests': { | 81 'tests': { |
61 'x': { | 82 'x': { |
62 'passing-test.html': { | 83 'passing-test.html': { |
63 'expected': 'PASS', | 84 'expected': 'PASS', |
64 'actual': 'PASS', | 85 'actual': 'PASS', |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 195 'two': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
175 } | 196 } |
176 } | 197 } |
177 self.assertEqual(updater.create_line_list(results), []) | 198 self.assertEqual(updater.create_line_list(results), []) |
178 | 199 |
179 def test_create_line_list_new_tests(self): | 200 def test_create_line_list_new_tests(self): |
180 # In this example, there are three unexpected results. The new | 201 # In this example, there are three unexpected results. The new |
181 # test expectation lines are sorted by test, and then specifier. | 202 # test expectation lines are sorted by test, and then specifier. |
182 updater = WPTExpectationsUpdater(self.mock_host()) | 203 updater = WPTExpectationsUpdater(self.mock_host()) |
183 results = { | 204 results = { |
184 'external/fake/test/zzzz.html': { | 205 'external/wpt/test/zzzz.html': { |
185 'test-mac-mac10.10': {'expected': 'PASS', 'actual': 'TEXT', 'bug
': 'crbug.com/test'}, | 206 'test-mac-mac10.10': {'expected': 'PASS', 'actual': 'TEXT', 'bug
': 'crbug.com/test'}, |
186 }, | 207 }, |
187 'external/fake/test/path.html': { | 208 'external/wpt/test/path.html': { |
188 'test-linux-trusty': {'expected': 'FAIL', 'actual': 'PASS', 'bug
': 'crbug.com/test'}, | 209 'test-linux-trusty': {'expected': 'FAIL', 'actual': 'PASS', 'bug
': 'crbug.com/test'}, |
189 'test-mac-mac10.11': {'expected': 'FAIL', 'actual': 'TIMEOUT', '
bug': 'crbug.com/test'}, | 210 'test-mac-mac10.11': {'expected': 'FAIL', 'actual': 'TIMEOUT', '
bug': 'crbug.com/test'}, |
190 }, | 211 }, |
191 } | 212 } |
192 self.assertEqual( | 213 self.assertEqual( |
193 updater.create_line_list(results), | 214 updater.create_line_list(results), |
194 [ | 215 [ |
195 'crbug.com/test [ Trusty ] external/fake/test/path.html [ Pass ]
', | 216 'crbug.com/test [ Trusty ] external/wpt/test/path.html [ Pass ]'
, |
196 'crbug.com/test [ Mac10.11 ] external/fake/test/path.html [ Time
out ]', | 217 'crbug.com/test [ Mac10.11 ] external/wpt/test/path.html [ Timeo
ut ]', |
197 'crbug.com/test [ Mac10.10 ] external/fake/test/zzzz.html [ Fail
ure ]', | 218 'crbug.com/test [ Mac10.10 ] external/wpt/test/zzzz.html [ Failu
re ]', |
198 ]) | 219 ]) |
199 | 220 |
200 def test_specifier_part(self): | 221 def test_specifier_part(self): |
201 updater = WPTExpectationsUpdater(self.mock_host()) | 222 updater = WPTExpectationsUpdater(self.mock_host()) |
202 self.assertEqual(updater.specifier_part(['test-mac-mac10.10'], 'x/y.html
'), '[ Mac10.10 ]') | 223 self.assertEqual(updater.specifier_part(['test-mac-mac10.10'], 'x/y.html
'), '[ Mac10.10 ]') |
203 self.assertEqual(updater.specifier_part([], 'x/y.html'), '') | 224 self.assertEqual(updater.specifier_part([], 'x/y.html'), '') |
204 | 225 |
205 def test_skipped_specifiers_when_test_is_wontfix(self): | 226 def test_skipped_specifiers_when_test_is_wontfix(self): |
206 host = self.mock_host() | 227 host = self.mock_host() |
207 expectations_path = '/test.checkout/LayoutTests/NeverFixTests' | 228 expectations_path = '/test.checkout/LayoutTests/NeverFixTests' |
208 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Trusty ] ext
ernal/wpt/test.html [ WontFix ]\n' | 229 host.filesystem.write_text_file( |
209 host.filesystem.files['/test.checkout/LayoutTests/external/wpt/test.html
'] = '' | 230 expectations_path, |
| 231 'crbug.com/111 [ Trusty ] external/wpt/test.html [ WontFix ]\n') |
| 232 host.filesystem.write_text_file('/test.checkout/LayoutTests/external/wpt
/test.html', '') |
210 updater = WPTExpectationsUpdater(host) | 233 updater = WPTExpectationsUpdater(host) |
211 self.assertEqual(updater.skipped_specifiers('external/wpt/test.html'), [
'Trusty']) | 234 self.assertEqual(updater.skipped_specifiers('external/wpt/test.html'), [
'Trusty']) |
212 | 235 |
213 def test_simplify_specifiers(self): | 236 def test_simplify_specifiers(self): |
214 macros = { | 237 macros = { |
215 'mac': ['Mac10.10', 'mac10.11'], | 238 'mac': ['Mac10.10', 'mac10.11'], |
216 'win': ['Win7', 'win10'], | 239 'win': ['Win7', 'win10'], |
217 'Linux': ['Trusty'], | 240 'Linux': ['Trusty'], |
218 } | 241 } |
219 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['mac10.10',
'mac10.11'], macros), ['Mac']) | 242 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['mac10.10',
'mac10.11'], macros), ['Mac']) |
220 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['Mac10.10',
'Mac10.11', 'Trusty'], macros), ['Linux', 'Mac']) | 243 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['Mac10.10',
'Mac10.11', 'Trusty'], macros), ['Linux', 'Mac']) |
221 self.assertEqual( | 244 self.assertEqual( |
222 WPTExpectationsUpdater.simplify_specifiers(['Mac10.10', 'Mac10.11',
'Trusty', 'Win7', 'Win10'], macros), []) | 245 WPTExpectationsUpdater.simplify_specifiers(['Mac10.10', 'Mac10.11',
'Trusty', 'Win7', 'Win10'], macros), []) |
223 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['a', 'b', '
c'], {}), ['A', 'B', 'C']) | 246 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['a', 'b', '
c'], {}), ['A', 'B', 'C']) |
224 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['Mac', 'Win
', 'Linux'], macros), []) | 247 self.assertEqual(WPTExpectationsUpdater.simplify_specifiers(['Mac', 'Win
', 'Linux'], macros), []) |
225 | 248 |
226 def test_specifier_part_with_skipped_test(self): | 249 def test_specifier_part_with_skipped_test(self): |
227 host = self.mock_host() | 250 host = self.mock_host() |
228 expectations_path = '/test.checkout/LayoutTests/NeverFixTests' | 251 expectations_path = '/test.checkout/LayoutTests/NeverFixTests' |
229 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Linux Mac10.
11 ] external/wpt/test.html [ WontFix ]\n' | 252 host.filesystem.write_text_file( |
230 host.filesystem.files['/test.checkout/LayoutTests/external/wpt/test.html
'] = '' | 253 expectations_path, |
| 254 'crbug.com/111 [ Linux Mac10.11 ] external/wpt/test.html [ WontFix ]
\n') |
| 255 host.filesystem.write_text_file('/test.checkout/LayoutTests/external/wpt
/test.html', '') |
231 updater = WPTExpectationsUpdater(host) | 256 updater = WPTExpectationsUpdater(host) |
232 self.assertEqual( | 257 self.assertEqual( |
233 updater.specifier_part(['test-mac-mac10.10', 'test-win-win7', 'test-
win-win10'], 'external/wpt/test.html'), '') | 258 updater.specifier_part(['test-mac-mac10.10', 'test-win-win7', 'test-
win-win10'], 'external/wpt/test.html'), '') |
234 self.assertEqual( | 259 self.assertEqual( |
235 updater.specifier_part(['test-win-win7', 'test-win-win10'], 'externa
l/wpt/another.html'), '[ Win ]') | 260 updater.specifier_part(['test-win-win7', 'test-win-win10'], 'externa
l/wpt/another.html'), '[ Win ]') |
236 | 261 |
237 def test_merge_dicts_with_conflict_raise_exception(self): | 262 def test_merge_dicts_with_conflict_raise_exception(self): |
238 updater = WPTExpectationsUpdater(self.mock_host()) | 263 updater = WPTExpectationsUpdater(self.mock_host()) |
239 # Both dicts here have the key "one", and the value is not equal. | 264 # Both dicts here have the key "one", and the value is not equal. |
240 with self.assertRaises(ValueError): | 265 with self.assertRaises(ValueError): |
241 updater.merge_dicts( | 266 updater.merge_dicts( |
242 { | 267 { |
243 'external/fake/test/path.html': { | 268 'external/wpt/test/path.html': { |
244 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 269 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
245 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 270 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
246 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 271 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
247 }, | 272 }, |
248 }, | 273 }, |
249 { | 274 { |
250 'external/fake/test/path.html': { | 275 'external/wpt/test/path.html': { |
251 'one': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 276 'one': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
252 } | 277 } |
253 }) | 278 }) |
254 | 279 |
255 def test_merge_dicts_merges_second_dict_into_first(self): | 280 def test_merge_dicts_merges_second_dict_into_first(self): |
256 updater = WPTExpectationsUpdater(self.mock_host()) | 281 updater = WPTExpectationsUpdater(self.mock_host()) |
257 one = { | 282 one = { |
258 'fake/test/path.html': { | 283 'fake/test/path.html': { |
259 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 284 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
260 'two': {'expected': 'FAIL', 'actual': 'PASS'}, | 285 'two': {'expected': 'FAIL', 'actual': 'PASS'}, |
261 } | 286 } |
262 } | 287 } |
263 two = { | 288 two = { |
264 'external/fake/test/path.html': { | 289 'external/wpt/test/path.html': { |
265 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 290 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
266 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 291 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
267 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 292 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
268 } | 293 } |
269 } | 294 } |
270 three = { | 295 three = { |
271 'external/fake/test/path.html': { | 296 'external/wpt/test/path.html': { |
272 'four': {'expected': 'FAIL', 'actual': 'PASS'}, | 297 'four': {'expected': 'FAIL', 'actual': 'PASS'}, |
273 } | 298 } |
274 } | 299 } |
275 | 300 |
276 output = updater.merge_dicts(one, three) | 301 output = updater.merge_dicts(one, three) |
277 self.assertEqual(output, one) | 302 self.assertEqual(output, one) |
278 output = updater.merge_dicts(two, three) | 303 output = updater.merge_dicts(two, three) |
279 self.assertEqual(output, two) | 304 self.assertEqual(output, two) |
280 | 305 |
281 def test_generate_results_dict(self): | 306 def test_generate_results_dict(self): |
(...skipping 14 matching lines...) Expand all Loading... |
296 'actual': 'foo', | 321 'actual': 'foo', |
297 'bug': 'crbug.com/626703', | 322 'bug': 'crbug.com/626703', |
298 } | 323 } |
299 } | 324 } |
300 }) | 325 }) |
301 | 326 |
302 def test_write_to_test_expectations_with_marker_comment(self): | 327 def test_write_to_test_expectations_with_marker_comment(self): |
303 host = self.mock_host() | 328 host = self.mock_host() |
304 | 329 |
305 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() | 330 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() |
306 host.filesystem.files[expectations_path] = MARKER_COMMENT + '\n' | 331 host.filesystem.write_text_file( |
| 332 expectations_path, |
| 333 MARKER_COMMENT + '\n') |
307 updater = WPTExpectationsUpdater(host) | 334 updater = WPTExpectationsUpdater(host) |
308 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'] | 335 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'] |
309 updater.write_to_test_expectations(line_list) | 336 updater.write_to_test_expectations(line_list) |
310 value = updater.host.filesystem.read_text_file(expectations_path) | 337 value = updater.host.filesystem.read_text_file(expectations_path) |
311 self.assertMultiLineEqual( | 338 self.assertMultiLineEqual( |
312 value, | 339 value, |
313 (MARKER_COMMENT + '\n' | 340 (MARKER_COMMENT + '\n' |
314 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n')) | 341 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n')) |
315 | 342 |
316 def test_write_to_test_expectations_with_no_marker_comment(self): | 343 def test_write_to_test_expectations_with_no_marker_comment(self): |
317 host = self.mock_host() | 344 host = self.mock_host() |
318 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() | 345 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() |
319 host.filesystem.files[expectations_path] = 'crbug.com/111 [ Trusty ] foo
/bar.html [ Failure ]\n' | 346 host.filesystem.write_text_file( |
| 347 expectations_path, |
| 348 'crbug.com/111 [ Trusty ] foo/bar.html [ Failure ]\n') |
320 updater = WPTExpectationsUpdater(host) | 349 updater = WPTExpectationsUpdater(host) |
321 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'] | 350 line_list = ['crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]'] |
322 updater.write_to_test_expectations(line_list) | 351 updater.write_to_test_expectations(line_list) |
323 value = host.filesystem.read_text_file(expectations_path) | 352 value = host.filesystem.read_text_file(expectations_path) |
324 self.assertMultiLineEqual( | 353 self.assertMultiLineEqual( |
325 value, | 354 value, |
326 ('crbug.com/111 [ Trusty ] foo/bar.html [ Failure ]\n' | 355 ('crbug.com/111 [ Trusty ] foo/bar.html [ Failure ]\n' |
327 '\n' + MARKER_COMMENT + '\n' | 356 '\n' + MARKER_COMMENT + '\n' |
328 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]')) | 357 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]')) |
329 | 358 |
330 def test_write_to_test_expectations_skips_existing_lines(self): | 359 def test_write_to_test_expectations_skips_existing_lines(self): |
331 host = self.mock_host() | 360 host = self.mock_host() |
332 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() | 361 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() |
333 host.filesystem.files[expectations_path] = 'crbug.com/111 dont/copy/me.h
tml [ Failure ]\n' | 362 host.filesystem.write_text_file( |
| 363 expectations_path, |
| 364 'crbug.com/111 dont/copy/me.html [ Failure ]\n') |
334 updater = WPTExpectationsUpdater(host) | 365 updater = WPTExpectationsUpdater(host) |
335 line_list = [ | 366 line_list = [ |
336 'crbug.com/111 dont/copy/me.html [ Failure ]', | 367 'crbug.com/111 dont/copy/me.html [ Failure ]', |
337 'crbug.com/222 do/copy/me.html [ Failure ]' | 368 'crbug.com/222 do/copy/me.html [ Failure ]' |
338 ] | 369 ] |
339 updater.write_to_test_expectations(line_list) | 370 updater.write_to_test_expectations(line_list) |
340 value = host.filesystem.read_text_file(expectations_path) | 371 value = host.filesystem.read_text_file(expectations_path) |
341 self.assertEqual( | 372 self.assertEqual( |
342 value, | 373 value, |
343 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' | 374 ('crbug.com/111 dont/copy/me.html [ Failure ]\n' |
344 '\n' + MARKER_COMMENT + '\n' | 375 '\n' + MARKER_COMMENT + '\n' |
345 'crbug.com/222 do/copy/me.html [ Failure ]')) | 376 'crbug.com/222 do/copy/me.html [ Failure ]')) |
346 | 377 |
347 def test_write_to_test_expectations_with_marker_and_no_lines(self): | 378 def test_write_to_test_expectations_with_marker_and_no_lines(self): |
348 host = self.mock_host() | 379 host = self.mock_host() |
349 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() | 380 expectations_path = host.port_factory.get().path_to_generic_test_expecta
tions_file() |
350 host.filesystem.files[expectations_path] = ( | 381 host.filesystem.write_text_file( |
351 MARKER_COMMENT + '\n' | 382 expectations_path, |
352 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n') | 383 MARKER_COMMENT + '\n' + 'crbug.com/123 [ Trusty ] fake/file/path.htm
l [ Pass ]\n') |
353 updater = WPTExpectationsUpdater(host) | 384 updater = WPTExpectationsUpdater(host) |
354 updater.write_to_test_expectations([]) | 385 updater.write_to_test_expectations([]) |
355 value = updater.host.filesystem.read_text_file(expectations_path) | 386 value = updater.host.filesystem.read_text_file(expectations_path) |
356 self.assertMultiLineEqual( | 387 self.assertMultiLineEqual( |
357 value, | 388 value, |
358 (MARKER_COMMENT + '\n' | 389 MARKER_COMMENT + '\n' + 'crbug.com/123 [ Trusty ] fake/file/path.htm
l [ Pass ]\n') |
359 'crbug.com/123 [ Trusty ] fake/file/path.html [ Pass ]\n')) | |
360 | 390 |
361 def test_is_js_test_true(self): | 391 def test_is_reference_test_given_testharness_test(self): |
362 host = self.mock_host() | 392 updater = WPTExpectationsUpdater(self.mock_host()) |
363 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo
/bar.html'] = ( | 393 self.assertFalse(updater.is_reference_test('test/path.html')) |
364 '<script src="/resources/testharness.js"></script>') | |
365 updater = WPTExpectationsUpdater(host) | |
366 self.assertTrue(updater.is_js_test('foo/bar.html')) | |
367 | 394 |
368 def test_is_js_test_false(self): | 395 def test_is_reference_test_given_reference_test(self): |
369 host = self.mock_host() | 396 updater = WPTExpectationsUpdater(self.mock_host()) |
370 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/foo
/bar.html'] = ( | 397 self.assertTrue(updater.is_reference_test('external/wpt/reftest.html')) |
371 '<script src="ref-test.html"></script>') | |
372 updater = WPTExpectationsUpdater(host) | |
373 self.assertFalse(updater.is_js_test('foo/bar.html')) | |
374 | 398 |
375 def test_is_js_test_non_existent_file(self): | 399 def test_is_reference_test_given_non_existent_file(self): |
376 updater = WPTExpectationsUpdater(self.mock_host()) | 400 updater = WPTExpectationsUpdater(self.mock_host()) |
377 self.assertFalse(updater.is_js_test('foo/bar.html')) | 401 self.assertFalse(updater.is_reference_test('foo/bar.html')) |
378 | 402 |
379 def test_get_test_to_rebaseline_returns_only_tests_with_failures(self): | 403 def test_get_test_to_rebaseline_returns_only_tests_with_failures(self): |
380 host = self.mock_host() | 404 host = self.mock_host() |
381 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/ext
ernal/fake/test/path.html'] = ( | |
382 '<script src="/resources/testharness.js"></script>') | |
383 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/ext
ernal/other/test/path.html'] = ( | |
384 '<script src="/resources/testharness.js"></script>') | |
385 updater = WPTExpectationsUpdater(host) | 405 updater = WPTExpectationsUpdater(host) |
386 two = { | 406 two = { |
387 'external/fake/test/path.html': { | 407 'external/wpt/test/path.html': { |
388 'one': {'expected': 'FAIL', 'actual': 'PASS'}, | 408 'one': {'expected': 'FAIL', 'actual': 'PASS'}, |
389 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, | 409 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT'}, |
390 'three': {'expected': 'FAIL', 'actual': 'PASS'}, | 410 'three': {'expected': 'FAIL', 'actual': 'PASS'}, |
391 } | 411 } |
392 } | 412 } |
393 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(two) | 413 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(two) |
394 # The other test doesn't have an entry in the test results dict, so it i
s not listed as a test to rebaseline. | 414 # external/wpt/test/zzzz.html is another possible candidate, but it |
395 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) | 415 # is not listed in the results dict, so it shall not be rebaselined. |
| 416 self.assertEqual(tests_to_rebaseline, ['external/wpt/test/path.html']) |
396 | 417 |
397 def test_get_test_to_rebaseline_returns_only_js_tests(self): | 418 def test_get_test_to_rebaseline_does_not_return_ref_tests(self): |
398 host = self.mock_host() | 419 host = self.mock_host() |
399 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/ext
ernal/fake/test/path.html'] = ( | |
400 'this file does not look like a testharness JS test.') | |
401 updater = WPTExpectationsUpdater(host) | 420 updater = WPTExpectationsUpdater(host) |
402 two = { | 421 two = { |
403 'external/fake/test/path.html': { | 422 'external/wpt/reftest.html': { |
404 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, | 423 'one': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.com/
test'}, |
405 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, | 424 'two': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.c
om/test'}, |
406 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, | 425 'three': {'expected': 'FAIL', 'actual': 'PASS', 'bug': 'crbug.co
m/test'}, |
407 } | 426 } |
408 } | 427 } |
409 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(two) | 428 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(two) |
410 self.assertEqual(tests_to_rebaseline, []) | 429 self.assertEqual(tests_to_rebaseline, []) |
411 | 430 |
412 def test_get_tests_to_rebaseline_returns_updated_dict(self): | 431 def test_get_tests_to_rebaseline_returns_updated_dict(self): |
413 host = self.mock_host() | 432 host = self.mock_host() |
414 test_results_dict = { | 433 results = { |
415 'external/fake/test/path.html': { | 434 'external/wpt/test/path.html': { |
416 'one': {'expected': 'PASS', 'actual': 'TEXT'}, | 435 'one': {'expected': 'PASS', 'actual': 'TEXT'}, |
417 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, | 436 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, |
418 }, | 437 }, |
419 } | 438 } |
420 test_results_dict_copy = copy.deepcopy(test_results_dict) | 439 results_copy = copy.deepcopy(results) |
421 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/ext
ernal/fake/test/path.html'] = ( | |
422 '<script src="/resources/testharness.js"></script>') | |
423 updater = WPTExpectationsUpdater(host) | 440 updater = WPTExpectationsUpdater(host) |
424 tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebase
line( | 441 tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebase
line(results) |
425 test_results_dict) | 442 self.assertEqual(tests_to_rebaseline, ['external/wpt/test/path.html']) |
426 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) | |
427 # The record for the builder with a timeout is kept, but not with a text
mismatch, | 443 # The record for the builder with a timeout is kept, but not with a text
mismatch, |
428 # since that should be covered by downloading a new baseline. | 444 # since that should be covered by downloading a new baseline. |
429 self.assertEqual(modified_test_results, { | 445 self.assertEqual(modified_test_results, { |
430 'external/fake/test/path.html': { | 446 'external/wpt/test/path.html': { |
431 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, | 447 'two': {'expected': 'PASS', 'actual': 'TIMEOUT'}, |
432 }, | 448 }, |
433 }) | 449 }) |
434 # The original dict isn't modified. | 450 # The original dict isn't modified. |
435 self.assertEqual(test_results_dict, test_results_dict_copy) | 451 self.assertEqual(results, results_copy) |
436 | 452 |
437 def test_get_tests_to_rebaseline_also_returns_slow_tests(self): | 453 def test_get_tests_to_rebaseline_also_returns_slow_tests(self): |
438 host = self.mock_host() | 454 host = self.mock_host() |
439 test_results_dict = { | 455 results = { |
440 'external/fake/test/path.html': { | 456 'external/wpt/test/path.html': { |
441 'one': {'expected': 'SLOW', 'actual': 'TEXT'}, | 457 'one': {'expected': 'SLOW', 'actual': 'TEXT'}, |
442 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, | 458 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, |
443 }, | 459 }, |
444 } | 460 } |
445 test_results_dict_copy = copy.deepcopy(test_results_dict) | 461 results_copy = copy.deepcopy(results) |
446 host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/ext
ernal/fake/test/path.html'] = ( | |
447 '<script src="/resources/testharness.js"></script>') | |
448 updater = WPTExpectationsUpdater(host) | 462 updater = WPTExpectationsUpdater(host) |
449 tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebase
line( | 463 tests_to_rebaseline, modified_test_results = updater.get_tests_to_rebase
line(results) |
450 test_results_dict) | 464 self.assertEqual(tests_to_rebaseline, ['external/wpt/test/path.html']) |
451 self.assertEqual(tests_to_rebaseline, ['external/fake/test/path.html']) | |
452 # The record for the builder with a timeout is kept, but not with a text
mismatch, | 465 # The record for the builder with a timeout is kept, but not with a text
mismatch, |
453 # since that should be covered by downloading a new baseline. | 466 # since that should be covered by downloading a new baseline. |
454 self.assertEqual(modified_test_results, { | 467 self.assertEqual(modified_test_results, { |
455 'external/fake/test/path.html': { | 468 'external/wpt/test/path.html': { |
456 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, | 469 'two': {'expected': 'SLOW', 'actual': 'TIMEOUT'}, |
457 }, | 470 }, |
458 }) | 471 }) |
459 # The original dict isn't modified. | 472 # The original dict isn't modified. |
460 self.assertEqual(test_results_dict, test_results_dict_copy) | 473 self.assertEqual(results, results_copy) |
461 | 474 |
462 def test_run_no_issue_number(self): | 475 def test_run_no_issue_number(self): |
463 # TODO(qyearsley): For testing: Consider making a MockGitCL class | 476 # TODO(qyearsley): For testing: Consider making a MockGitCL class |
464 # and use that class to set fake return values when using git cl. | 477 # and use that class to set fake return values when using git cl. |
465 updater = WPTExpectationsUpdater(self.mock_host()) | 478 updater = WPTExpectationsUpdater(self.mock_host()) |
466 updater.get_issue_number = lambda: 'None' | 479 updater.get_issue_number = lambda: 'None' |
467 self.assertEqual(1, updater.run(args=[])) | 480 self.assertEqual(1, updater.run(args=[])) |
468 self.assertLog(['ERROR: No issue on current branch.\n']) | 481 self.assertLog(['ERROR: No issue on current branch.\n']) |
469 | 482 |
470 def test_run_no_try_results(self): | 483 def test_run_no_try_results(self): |
471 updater = WPTExpectationsUpdater(self.mock_host()) | 484 updater = WPTExpectationsUpdater(self.mock_host()) |
472 updater.get_latest_try_jobs = lambda: [] | 485 updater.get_latest_try_jobs = lambda: [] |
473 self.assertEqual(1, updater.run(args=[])) | 486 self.assertEqual(1, updater.run(args=[])) |
474 self.assertLog(['ERROR: No try job information was collected.\n']) | 487 self.assertLog(['ERROR: No try job information was collected.\n']) |
475 | 488 |
476 def test_new_manual_tests_get_skip_expectation(self): | 489 def test_new_manual_tests_get_skip_expectation(self): |
477 host = self.mock_host() | 490 host = self.mock_host() |
478 host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layou
tTests/external/wpt/x-manual.html', '<html>') | |
479 updater = WPTExpectationsUpdater(host) | 491 updater = WPTExpectationsUpdater(host) |
480 results = { | 492 results = { |
481 'external/wpt/x-manual.html': { | 493 'external/wpt/x-manual.html': { |
482 ( | 494 ( |
483 'test-linux-precise', | 495 'test-linux-precise', |
484 'test-linux-trusty', | 496 'test-linux-trusty', |
485 'test-mac-mac10.10', | 497 'test-mac-mac10.10', |
486 'test-mac-mac10.11', | 498 'test-mac-mac10.11', |
487 'test-win-win7', | 499 'test-win-win7', |
488 'test-win-win10', | 500 'test-win-win10', |
489 ): {'expected': 'PASS', 'actual': 'MISSING', 'bug': 'crbug.com/t
est'} | 501 ): {'expected': 'PASS', 'actual': 'MISSING', 'bug': 'crbug.com/t
est'} |
490 } | 502 } |
491 } | 503 } |
492 results_copy = copy.deepcopy(results) | 504 tests_to_rebaseline, _ = updater.get_tests_to_rebaseline(results) |
493 self.assertEqual( | 505 self.assertEqual(tests_to_rebaseline, []) |
494 updater.get_tests_to_rebaseline(results), | |
495 ([], results_copy)) | |
496 self.assertEqual( | 506 self.assertEqual( |
497 updater.create_line_list(results), | 507 updater.create_line_list(results), |
498 ['crbug.com/test external/wpt/x-manual.html [ Skip ]']) | 508 ['crbug.com/test external/wpt/x-manual.html [ Skip ]']) |
OLD | NEW |