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.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 |
11 from webkitpy.common.system.output_capture import OutputCapture | 11 from webkitpy.common.system.output_capture import OutputCapture |
12 from webkitpy.layout_tests.builder_list import BuilderList | 12 from webkitpy.layout_tests.builder_list import BuilderList |
| 13 from webkitpy.layout_tests.port.factory_mock import MockPortFactory |
13 from webkitpy.tool.commands.rebaseline import ( | 14 from webkitpy.tool.commands.rebaseline import ( |
14 AbstractParallelRebaselineCommand, CopyExistingBaselinesInternal, | 15 AbstractParallelRebaselineCommand, CopyExistingBaselinesInternal, |
15 Rebaseline, RebaselineExpectations, RebaselineJson, RebaselineTest | 16 Rebaseline, RebaselineExpectations, RebaselineJson, RebaselineTest, |
| 17 TestBaselineSet |
16 ) | 18 ) |
17 from webkitpy.tool.mock_tool import MockWebKitPatch | 19 from webkitpy.tool.mock_tool import MockWebKitPatch |
18 | 20 |
19 | 21 |
20 # pylint: disable=protected-access | 22 # pylint: disable=protected-access |
21 class BaseTestCase(unittest.TestCase): | 23 class BaseTestCase(unittest.TestCase): |
| 24 |
22 WEB_PREFIX = 'https://storage.googleapis.com/chromium-layout-test-archives/M
OCK_Mac10_11/results/layout-test-results' | 25 WEB_PREFIX = 'https://storage.googleapis.com/chromium-layout-test-archives/M
OCK_Mac10_11/results/layout-test-results' |
23 | 26 |
24 command_constructor = None | 27 command_constructor = lambda: None |
25 | 28 |
26 def setUp(self): | 29 def setUp(self): |
27 self.tool = MockWebKitPatch() | 30 self.tool = MockWebKitPatch() |
28 # Lint warns that command_constructor might not be set, but this is inte
ntional; pylint: disable=not-callable | 31 self.command = None |
29 self.command = self.command_constructor() | 32 self.command = self.command_constructor() |
30 self.command._tool = self.tool | 33 self.command._tool = self.tool |
31 self.tool.builders = BuilderList({ | 34 self.tool.builders = BuilderList({ |
32 'MOCK Mac10.10 (dbg)': {'port_name': 'test-mac-mac10.10', 'specifier
s': ['Mac10.10', 'Debug']}, | 35 'MOCK Mac10.10 (dbg)': {'port_name': 'test-mac-mac10.10', 'specifier
s': ['Mac10.10', 'Debug']}, |
33 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['
Mac10.10', 'Release']}, | 36 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['
Mac10.10', 'Release']}, |
34 'MOCK Mac10.11 (dbg)': {'port_name': 'test-mac-mac10.11', 'specifier
s': ['Mac10.11', 'Debug']}, | 37 'MOCK Mac10.11 (dbg)': {'port_name': 'test-mac-mac10.11', 'specifier
s': ['Mac10.11', 'Debug']}, |
35 'MOCK Mac10.11 ASAN': {'port_name': 'test-mac-mac10.11', 'specifiers
': ['Mac10.11', 'Release']}, | 38 'MOCK Mac10.11 ASAN': {'port_name': 'test-mac-mac10.11', 'specifiers
': ['Mac10.11', 'Release']}, |
36 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['
Mac10.11', 'Release']}, | 39 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['
Mac10.11', 'Release']}, |
37 'MOCK Precise': {'port_name': 'test-linux-precise', 'specifiers': ['
Precise', 'Release']}, | 40 'MOCK Precise': {'port_name': 'test-linux-precise', 'specifiers': ['
Precise', 'Release']}, |
38 'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Tr
usty', 'Release']}, | 41 'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Tr
usty', 'Release']}, |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 self.assertMultiLineEqual( | 321 self.assertMultiLineEqual( |
319 out, '{"remove-lines": [{"test": "failures/expected/image.html", "bu
ilder": "MOCK Win10"}]}\n') | 322 out, '{"remove-lines": [{"test": "failures/expected/image.html", "bu
ilder": "MOCK Win10"}]}\n') |
320 | 323 |
321 | 324 |
322 class TestAbstractParallelRebaselineCommand(BaseTestCase): | 325 class TestAbstractParallelRebaselineCommand(BaseTestCase): |
323 command_constructor = AbstractParallelRebaselineCommand | 326 command_constructor = AbstractParallelRebaselineCommand |
324 | 327 |
325 def test_builders_to_fetch_from(self): | 328 def test_builders_to_fetch_from(self): |
326 builders_to_fetch = self.command._builders_to_fetch_from( | 329 builders_to_fetch = self.command._builders_to_fetch_from( |
327 ['MOCK Win10', 'MOCK Win7 (dbg)(1)', 'MOCK Win7 (dbg)(2)', 'MOCK Win
7']) | 330 ['MOCK Win10', 'MOCK Win7 (dbg)(1)', 'MOCK Win7 (dbg)(2)', 'MOCK Win
7']) |
328 self.assertEqual(builders_to_fetch, ['MOCK Win7', 'MOCK Win10']) | 331 self.assertEqual(builders_to_fetch, {'MOCK Win7', 'MOCK Win10'}) |
329 | 332 |
330 def test_all_baseline_paths(self): | 333 def test_possible_baseline_paths(self): |
331 test_prefix_list = { | 334 test_baseline_set = TestBaselineSet(self.tool) |
332 'passes/text.html': [ | 335 test_baseline_set.add('passes/text.html', Build('MOCK Win7')) |
333 Build('MOCK Win7'), | 336 test_baseline_set.add('passes/text.html', Build('MOCK Win10')) |
334 Build('MOCK Win10'), | 337 |
335 ] | |
336 } | |
337 # pylint: disable=protected-access | 338 # pylint: disable=protected-access |
338 baseline_paths = self.command._all_baseline_paths(test_prefix_list) | 339 baseline_paths = self.command._possible_baseline_paths(test_baseline_set
) |
339 self.assertEqual(baseline_paths, [ | 340 self.assertEqual(baseline_paths, [ |
340 '/test.checkout/LayoutTests/passes/text-expected.png', | 341 '/test.checkout/LayoutTests/passes/text-expected.png', |
341 '/test.checkout/LayoutTests/passes/text-expected.txt', | 342 '/test.checkout/LayoutTests/passes/text-expected.txt', |
342 '/test.checkout/LayoutTests/passes/text-expected.wav', | 343 '/test.checkout/LayoutTests/passes/text-expected.wav', |
343 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.png', | 344 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.png', |
344 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.txt', | 345 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.txt', |
345 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.wav', | 346 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.wav', |
346 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.png', | 347 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.png', |
347 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.txt', | 348 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.txt', |
348 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.wav', | 349 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.wav', |
349 ]) | 350 ]) |
350 | 351 |
351 def test_remove_all_pass_testharness_baselines(self): | 352 def test_remove_all_pass_testharness_baselines(self): |
352 self.tool.filesystem.write_text_file( | 353 self.tool.filesystem.write_text_file( |
353 '/test.checkout/LayoutTests/passes/text-expected.txt', | 354 '/test.checkout/LayoutTests/passes/text-expected.txt', |
354 ('This is a testharness.js-based test.\n' | 355 ('This is a testharness.js-based test.\n' |
355 'PASS: foo\n' | 356 'PASS: foo\n' |
356 'Harness: the test ran to completion.\n')) | 357 'Harness: the test ran to completion.\n')) |
357 test_prefix_list = { | 358 test_baseline_set = TestBaselineSet(self.tool) |
358 'passes/text.html': [ | 359 test_baseline_set.add('passes/text.html', Build('MOCK Win7')) |
359 Build('MOCK Win7'), | 360 test_baseline_set.add('passes/text.html', Build('MOCK Win10')) |
360 Build('MOCK Win10'), | 361 self.command._remove_all_pass_testharness_baselines(test_baseline_set) |
361 ] | |
362 } | |
363 self.command._remove_all_pass_testharness_baselines(test_prefix_list) | |
364 self.assertFalse(self.tool.filesystem.exists( | 362 self.assertFalse(self.tool.filesystem.exists( |
365 '/test.checkout/LayoutTests/passes/text-expected.txt')) | 363 '/test.checkout/LayoutTests/passes/text-expected.txt')) |
366 | 364 |
367 | 365 |
368 class TestRebaselineJson(BaseTestCase): | 366 class TestRebaselineJson(BaseTestCase): |
369 command_constructor = RebaselineJson | 367 command_constructor = RebaselineJson |
370 | 368 |
371 def setUp(self): | 369 def setUp(self): |
372 super(TestRebaselineJson, self).setUp() | 370 super(TestRebaselineJson, self).setUp() |
373 self.tool.executive = MockExecutive() | 371 self.tool.executive = MockExecutive() |
(...skipping 18 matching lines...) Expand all Loading... |
392 'first-test.html': { | 390 'first-test.html': { |
393 'expected': 'NEEDSREBASELINE', | 391 'expected': 'NEEDSREBASELINE', |
394 'actual': 'PASS' | 392 'actual': 'PASS' |
395 } | 393 } |
396 } | 394 } |
397 } | 395 } |
398 })) | 396 })) |
399 | 397 |
400 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') | 398 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') |
401 self._write('userscripts/first-test.html', 'Dummy test contents') | 399 self._write('userscripts/first-test.html', 'Dummy test contents') |
402 self.command.rebaseline(self.options(), {'userscripts/first-test.html':
{Build('MOCK Win7'): ['txt', 'png']}}) | 400 test_baseline_set = TestBaselineSet(self.tool) |
| 401 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Win7')) |
| 402 self.command.rebaseline(self.options(), test_baseline_set) |
403 | 403 |
404 self.assertEqual(self.tool.executive.calls, []) | 404 self.assertEqual(self.tool.executive.calls, []) |
405 | 405 |
406 def test_rebaseline_all(self): | 406 def test_rebaseline_all(self): |
407 self._setup_mock_build_data() | 407 self._setup_mock_build_data() |
408 | 408 |
409 self._write('userscripts/first-test.html', 'Dummy test contents') | 409 self._write('userscripts/first-test.html', 'Dummy test contents') |
410 self.command.rebaseline(self.options(), {'userscripts/first-test.html':
{Build('MOCK Win7'): ['txt', 'png']}}) | 410 test_baseline_set = TestBaselineSet(self.tool) |
| 411 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Win7')) |
| 412 self.command.rebaseline(self.options(), test_baseline_set) |
411 | 413 |
412 # Note that we have one run_in_parallel() call followed by a run_command
() | |
413 self.assertEqual( | 414 self.assertEqual( |
414 self.tool.executive.calls, | 415 self.tool.executive.calls, |
415 [ | 416 [ |
416 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', | 417 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', |
417 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], | 418 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], |
418 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', | 419 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', |
419 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], | 420 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], |
420 [['python', 'echo', 'optimize-baselines', '--suffixes', 'txt,png
', | 421 [['python', 'echo', 'optimize-baselines', '--suffixes', 'txt,png
', |
421 'userscripts/first-test.html', '--verbose']] | 422 'userscripts/first-test.html', '--verbose']] |
422 ]) | 423 ]) |
423 | 424 |
424 def test_rebaseline_debug(self): | 425 def test_rebaseline_debug(self): |
425 self._setup_mock_build_data() | 426 self._setup_mock_build_data() |
| 427 self._write('userscripts/first-test.html', 'Dummy test contents') |
| 428 test_baseline_set = TestBaselineSet(self.tool) |
| 429 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Win7 (d
bg)')) |
426 | 430 |
427 self._write('userscripts/first-test.html', 'Dummy test contents') | 431 self.command.rebaseline(self.options(), test_baseline_set) |
428 self.command.rebaseline(self.options(), {'userscripts/first-test.html':
{Build('MOCK Win7 (dbg)'): ['txt', 'png']}}) | |
429 | 432 |
430 # Note that we have one run_in_parallel() call followed by a run_command
() | |
431 self.assertEqual( | 433 self.assertEqual( |
432 self.tool.executive.calls, | 434 self.tool.executive.calls, |
433 [ | 435 [ |
434 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', | 436 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', |
435 '--builder', 'MOCK Win7 (dbg)', '--test', 'userscripts/first-t
est.html', '--verbose']], | 437 '--builder', 'MOCK Win7 (dbg)', '--test', 'userscripts/first-t
est.html', '--verbose']], |
436 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', '--builder', | 438 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', '--builder', |
437 'MOCK Win7 (dbg)', '--test', 'userscripts/first-test.html', '-
-verbose']], | 439 'MOCK Win7 (dbg)', '--test', 'userscripts/first-test.html', '-
-verbose']], |
438 [['python', 'echo', 'optimize-baselines', '--suffixes', 'txt,png
', | 440 [['python', 'echo', 'optimize-baselines', '--suffixes', 'txt,png
', |
439 'userscripts/first-test.html', '--verbose']] | 441 'userscripts/first-test.html', '--verbose']] |
440 ]) | 442 ]) |
441 | 443 |
442 def test_no_optimize(self): | 444 def test_no_optimize(self): |
443 self._setup_mock_build_data() | 445 self._setup_mock_build_data() |
444 self._write('userscripts/first-test.html', 'Dummy test contents') | 446 self._write('userscripts/first-test.html', 'Dummy test contents') |
445 self.command.rebaseline( | 447 test_baseline_set = TestBaselineSet(self.tool) |
446 self.options(optimize=False), | 448 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Win7')) |
447 {'userscripts/first-test.html': {Build('MOCK Win7'): ['txt', 'png']}
}) | 449 self.command.rebaseline(self.options(optimize=False), test_baseline_set) |
448 | 450 |
449 # Note that we have only one run_in_parallel() call | |
450 self.assertEqual( | 451 self.assertEqual( |
451 self.tool.executive.calls, | 452 self.tool.executive.calls, |
452 [ | 453 [ |
453 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', | 454 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', |
454 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], | 455 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], |
455 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', | 456 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', |
456 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']] | 457 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']] |
457 ]) | 458 ]) |
458 | 459 |
459 def test_results_directory(self): | 460 def test_results_directory(self): |
460 self._setup_mock_build_data() | 461 self._setup_mock_build_data() |
461 self._write('userscripts/first-test.html', 'Dummy test contents') | 462 self._write('userscripts/first-test.html', 'Dummy test contents') |
462 self.command.rebaseline( | 463 test_baseline_set = TestBaselineSet(self.tool) |
463 self.options(optimize=False, results_directory='/tmp'), | 464 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Win7')) |
464 {'userscripts/first-test.html': {Build('MOCK Win7'): ['txt', 'png']}
}) | 465 self.command.rebaseline(self.options(optimize=False, results_directory='
/tmp'), test_baseline_set) |
465 | 466 |
466 # Note that we have only one run_in_parallel() call | |
467 self.assertEqual( | 467 self.assertEqual( |
468 self.tool.executive.calls, | 468 self.tool.executive.calls, |
469 [ | 469 [ |
470 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', | 470 [['python', 'echo', 'copy-existing-baselines-internal', '--suffi
xes', 'txt,png', |
471 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], | 471 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose']], |
472 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', | 472 [['python', 'echo', 'rebaseline-test-internal', '--suffixes', 't
xt,png', |
473 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose', '--results-directory', '/tmp']] | 473 '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.ht
ml', '--verbose', '--results-directory', '/tmp']] |
474 ]) | 474 ]) |
475 | 475 |
476 def test_unstaged_baselines(self): | 476 def test_unstaged_baselines(self): |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 'results_directory': None | 509 'results_directory': None |
510 }) | 510 }) |
511 | 511 |
512 def test_rebaseline_updates_expectations_file(self): | 512 def test_rebaseline_updates_expectations_file(self): |
513 self._write( | 513 self._write( |
514 self.mac_expectations_path, | 514 self.mac_expectations_path, |
515 ('Bug(x) [ Mac ] userscripts/first-test.html [ Failure ]\n' | 515 ('Bug(x) [ Mac ] userscripts/first-test.html [ Failure ]\n' |
516 'bug(z) [ Linux ] userscripts/first-test.html [ Failure ]\n')) | 516 'bug(z) [ Linux ] userscripts/first-test.html [ Failure ]\n')) |
517 self._write('userscripts/first-test.html', 'Dummy test contents') | 517 self._write('userscripts/first-test.html', 'Dummy test contents') |
518 self._setup_mock_build_data() | 518 self._setup_mock_build_data() |
| 519 test_baseline_set = TestBaselineSet(self.tool) |
| 520 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Mac10.1
1')) |
519 | 521 |
520 self.command.rebaseline( | 522 self.command.rebaseline(self.options(), test_baseline_set) |
521 self.options(), | |
522 {'userscripts/first-test.html': {Build('MOCK Mac10.11'): ['txt', 'pn
g']}}) | |
523 | 523 |
524 new_expectations = self._read(self.mac_expectations_path) | 524 new_expectations = self._read(self.mac_expectations_path) |
525 self.assertMultiLineEqual( | 525 self.assertMultiLineEqual( |
526 new_expectations, | 526 new_expectations, |
527 ('Bug(x) [ Mac10.10 ] userscripts/first-test.html [ Failure ]\n' | 527 ('Bug(x) [ Mac10.10 ] userscripts/first-test.html [ Failure ]\n' |
528 'bug(z) [ Linux ] userscripts/first-test.html [ Failure ]\n')) | 528 'bug(z) [ Linux ] userscripts/first-test.html [ Failure ]\n')) |
529 | 529 |
530 def test_rebaseline_updates_expectations_file_all_platforms(self): | 530 def test_rebaseline_updates_expectations_file_all_platforms(self): |
531 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') | 531 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') |
532 self._write('userscripts/first-test.html', 'Dummy test contents') | 532 self._write('userscripts/first-test.html', 'Dummy test contents') |
533 self._setup_mock_build_data() | 533 self._setup_mock_build_data() |
534 self.command.rebaseline( | 534 test_baseline_set = TestBaselineSet(self.tool) |
535 self.options(), | 535 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Mac10.1
1')) |
536 {'userscripts/first-test.html': {Build('MOCK Mac10.11'): ['txt', 'pn
g']}}) | 536 |
| 537 self.command.rebaseline(self.options(), test_baseline_set) |
| 538 |
537 new_expectations = self._read(self.mac_expectations_path) | 539 new_expectations = self._read(self.mac_expectations_path) |
538 self.assertMultiLineEqual( | 540 self.assertMultiLineEqual( |
539 new_expectations, 'Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n') | 541 new_expectations, 'Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n') |
540 | 542 |
541 def test_rebaseline_handles_platform_skips(self): | 543 def test_rebaseline_handles_platform_skips(self): |
542 # This test is just like test_rebaseline_updates_expectations_file_all_p
latforms(), | 544 # This test is just like test_rebaseline_updates_expectations_file_all_p
latforms(), |
543 # except that if a particular port happens to SKIP a test in an override
s file, | 545 # except that if a particular port happens to SKIP a test in an override
s file, |
544 # we count that as passing, and do not think that we still need to rebas
eline it. | 546 # we count that as passing, and do not think that we still need to rebas
eline it. |
545 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') | 547 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') |
546 self._write('NeverFixTests', 'Bug(y) [ Android ] userscripts [ WontFix ]
\n') | 548 self._write('NeverFixTests', 'Bug(y) [ Android ] userscripts [ WontFix ]
\n') |
547 self._write('userscripts/first-test.html', 'Dummy test contents') | 549 self._write('userscripts/first-test.html', 'Dummy test contents') |
548 self._setup_mock_build_data() | 550 self._setup_mock_build_data() |
| 551 test_baseline_set = TestBaselineSet(self.tool) |
| 552 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Mac10.1
1')) |
549 | 553 |
550 self.command.rebaseline( | 554 self.command.rebaseline(self.options(), test_baseline_set) |
551 self.options(), | |
552 {'userscripts/first-test.html': {Build('MOCK Mac10.11'): ['txt', 'pn
g']}}) | |
553 | 555 |
554 new_expectations = self._read(self.mac_expectations_path) | 556 new_expectations = self._read(self.mac_expectations_path) |
555 self.assertMultiLineEqual( | 557 self.assertMultiLineEqual( |
556 new_expectations, 'Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n') | 558 new_expectations, 'Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n') |
557 | 559 |
558 def test_rebaseline_handles_skips_in_file(self): | 560 def test_rebaseline_handles_skips_in_file(self): |
559 # This test is like test_Rebaseline_handles_platform_skips, except that
the | 561 # This test is like test_Rebaseline_handles_platform_skips, except that
the |
560 # Skip is in the same (generic) file rather than a platform file. In thi
s case, | 562 # Skip is in the same (generic) file rather than a platform file. In thi
s case, |
561 # the Skip line should be left unmodified. Note that the first line is n
ow | 563 # the Skip line should be left unmodified. Note that the first line is n
ow |
562 # qualified as "[Linux Mac Win]"; if it was unqualified, it would confli
ct with | 564 # qualified as "[Linux Mac Win]"; if it was unqualified, it would confli
ct with |
563 # the second line. | 565 # the second line. |
564 self._write(self.mac_expectations_path, | 566 self._write(self.mac_expectations_path, |
565 ('Bug(x) [ Linux Mac Win ] userscripts/first-test.html [ Fai
lure ]\n' | 567 ('Bug(x) [ Linux Mac Win ] userscripts/first-test.html [ Fai
lure ]\n' |
566 'Bug(y) [ Android ] userscripts/first-test.html [ Skip ]\n'
)) | 568 'Bug(y) [ Android ] userscripts/first-test.html [ Skip ]\n'
)) |
567 self._write('userscripts/first-test.html', 'Dummy test contents') | 569 self._write('userscripts/first-test.html', 'Dummy test contents') |
568 self._setup_mock_build_data() | 570 self._setup_mock_build_data() |
| 571 test_baseline_set = TestBaselineSet(self.tool) |
| 572 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Mac10.1
1')) |
569 | 573 |
570 self.command.rebaseline( | 574 self.command.rebaseline(self.options(), test_baseline_set) |
571 self.options(), | |
572 {'userscripts/first-test.html': {Build('MOCK Mac10.11'): ['txt', 'pn
g']}}) | |
573 | 575 |
574 new_expectations = self._read(self.mac_expectations_path) | 576 new_expectations = self._read(self.mac_expectations_path) |
575 self.assertMultiLineEqual( | 577 self.assertMultiLineEqual( |
576 new_expectations, | 578 new_expectations, |
577 ('Bug(x) [ Linux Mac10.10 Win ] userscripts/first-test.html [ Failur
e ]\n' | 579 ('Bug(x) [ Linux Mac10.10 Win ] userscripts/first-test.html [ Failur
e ]\n' |
578 'Bug(y) [ Android ] userscripts/first-test.html [ Skip ]\n')) | 580 'Bug(y) [ Android ] userscripts/first-test.html [ Skip ]\n')) |
579 | 581 |
580 def test_rebaseline_handles_smoke_tests(self): | 582 def test_rebaseline_handles_smoke_tests(self): |
581 # This test is just like test_rebaseline_handles_platform_skips, except
that we check for | 583 # This test is just like test_rebaseline_handles_platform_skips, except
that we check for |
582 # a test not being in the SmokeTests file, instead of using overrides fi
les. | 584 # a test not being in the SmokeTests file, instead of using overrides fi
les. |
583 # If a test is not part of the smoke tests, we count that as passing on
ports that only | 585 # If a test is not part of the smoke tests, we count that as passing on
ports that only |
584 # run smoke tests, and do not think that we still need to rebaseline it. | 586 # run smoke tests, and do not think that we still need to rebaseline it. |
585 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') | 587 self._write(self.mac_expectations_path, 'Bug(x) userscripts/first-test.h
tml [ Failure ]\n') |
586 self._write('SmokeTests', 'fast/html/article-element.html') | 588 self._write('SmokeTests', 'fast/html/article-element.html') |
587 self._write('userscripts/first-test.html', 'Dummy test contents') | 589 self._write('userscripts/first-test.html', 'Dummy test contents') |
588 self._setup_mock_build_data() | 590 self._setup_mock_build_data() |
| 591 test_baseline_set = TestBaselineSet(self.tool) |
| 592 test_baseline_set.add('userscripts/first-test.html', Build('MOCK Mac10.1
1')) |
589 | 593 |
590 self.command.rebaseline( | 594 self.command.rebaseline(self.options(), test_baseline_set) |
591 self.options(), | |
592 {'userscripts/first-test.html': {Build('MOCK Mac10.11'): ['txt', 'pn
g']}}) | |
593 | 595 |
594 new_expectations = self._read(self.mac_expectations_path) | 596 new_expectations = self._read(self.mac_expectations_path) |
595 self.assertMultiLineEqual( | 597 self.assertMultiLineEqual( |
596 new_expectations, 'Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n') | 598 new_expectations, 'Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n') |
597 | 599 |
598 | 600 |
599 class TestRebaseline(BaseTestCase): | 601 class TestRebaseline(BaseTestCase): |
600 # This command shares most of its logic with RebaselineJson, so these tests
just test what is different. | 602 # This command shares most of its logic with RebaselineJson, so these tests
just test what is different. |
601 | 603 |
602 command_constructor = Rebaseline # AKA webkit-patch rebaseline | 604 command_constructor = Rebaseline # AKA webkit-patch rebaseline |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 [ | 783 [ |
782 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 784 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
783 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/reftest-te
xt.html'], | 785 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/reftest-te
xt.html'], |
784 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 786 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
785 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/reftest-te
xt.html'], | 787 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/reftest-te
xt.html'], |
786 ], | 788 ], |
787 ]) | 789 ]) |
788 | 790 |
789 def test_rebaseline_expectations_noop(self): | 791 def test_rebaseline_expectations_noop(self): |
790 self._zero_out_test_expectations() | 792 self._zero_out_test_expectations() |
791 | 793 self.command.execute(self.options(), [], self.tool) |
792 oc = OutputCapture() | 794 self.assertEqual(self.tool.filesystem.written_files, {}) |
793 try: | |
794 oc.capture_output() | |
795 self.command.execute(self.options(), [], self.tool) | |
796 finally: | |
797 _, _, logs = oc.restore_output() | |
798 self.assertEqual(self.tool.filesystem.written_files, {}) | |
799 self.assertEqual(logs, 'Did not find any tests marked Rebaseline.\n'
) | |
800 | 795 |
801 def disabled_test_overrides_are_included_correctly(self): | 796 def disabled_test_overrides_are_included_correctly(self): |
802 # TODO(qyearsley): Fix or remove this test method. | 797 # TODO(qyearsley): Fix or remove this test method. |
803 # This tests that any tests marked as REBASELINE in the overrides are fo
und, but | 798 # This tests that any tests marked as REBASELINE in the overrides are fo
und, but |
804 # that the overrides do not get written into the main file. | 799 # that the overrides do not get written into the main file. |
805 self._zero_out_test_expectations() | 800 self._zero_out_test_expectations() |
806 | 801 |
807 self._write(self.mac_expectations_path, '') | 802 self._write(self.mac_expectations_path, '') |
808 self.mac_port.expectations_dict = lambda: { | 803 self.mac_port.expectations_dict = lambda: { |
809 self.mac_expectations_path: '', | 804 self.mac_expectations_path: '', |
(...skipping 21 matching lines...) Expand all Loading... |
831 'prototype-taco.html': { | 826 'prototype-taco.html': { |
832 'expected': 'FAIL', | 827 'expected': 'FAIL', |
833 'actual': 'PASS', | 828 'actual': 'PASS', |
834 'is_unexpected': True | 829 'is_unexpected': True |
835 } | 830 } |
836 } | 831 } |
837 } | 832 } |
838 } | 833 } |
839 })) | 834 })) |
840 | 835 |
841 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe
ctations_file(), """ | 836 self.tool.filesystem.write_text_file( |
842 Bug(foo) fast/dom/prototype-taco.html [ Rebaseline ] | 837 test_port.path_to_generic_test_expectations_file(), |
843 """) | 838 'Bug(foo) fast/dom/prototype-taco.html [ Rebaseline ]\n') |
844 | 839 |
845 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', 'Dummy
test contents') | 840 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', 'Dummy
test contents') |
846 | 841 |
847 self.tool.executive = MockLineRemovingExecutive() | 842 self.tool.executive = MockLineRemovingExecutive() |
848 | 843 |
849 self.tool.builders = BuilderList({ | 844 self.tool.builders = BuilderList({ |
850 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['
Mac10.10', 'Release']}, | 845 'MOCK Mac10.10': {'port_name': 'test-mac-mac10.10', 'specifiers': ['
Mac10.10', 'Release']}, |
851 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['
Mac10.11', 'Release']}, | 846 'MOCK Mac10.11': {'port_name': 'test-mac-mac10.11', 'specifiers': ['
Mac10.11', 'Release']}, |
852 }) | 847 }) |
853 | 848 |
854 self.command.execute(self.options(), [], self.tool) | 849 self.command.execute(self.options(), [], self.tool) |
855 self.assertEqual(self.tool.executive.calls, []) | 850 self.assertEqual(self.tool.executive.calls, []) |
856 | 851 |
857 # The mac ports should both be removed since they're the only ones in th
e builder list. | 852 # The mac ports should both be removed since they're the only ones in th
e builder list. |
858 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g
eneric_test_expectations_file()), """ | 853 self.assertEqual( |
859 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ Rebaseline ] | 854 self.tool.filesystem.read_text_file(test_port.path_to_generic_test_e
xpectations_file()), |
860 """) | 855 'Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ Rebaseline ]\
n') |
861 | 856 |
862 def test_rebaseline_missing(self): | 857 def test_rebaseline_missing(self): |
863 self.tool.buildbot.set_results(Build('MOCK Mac10.10'), LayoutTestResults
({ | 858 self.tool.buildbot.set_results(Build('MOCK Mac10.10'), LayoutTestResults
({ |
864 'tests': { | 859 'tests': { |
865 'fast': { | 860 'fast': { |
866 'dom': { | 861 'dom': { |
867 'missing-text.html': { | 862 'missing-text.html': { |
868 'expected': 'PASS', | 863 'expected': 'PASS', |
869 'actual': 'MISSING', | 864 'actual': 'MISSING', |
870 'is_unexpected': True, | 865 'is_unexpected': True, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 for cmd_line, cwd in commands: | 925 for cmd_line, cwd in commands: |
931 out = self.run_command(cmd_line, cwd=cwd) | 926 out = self.run_command(cmd_line, cwd=cwd) |
932 if 'rebaseline-test-internal' in cmd_line: | 927 if 'rebaseline-test-internal' in cmd_line: |
933 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) | 928 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) |
934 command_outputs.append([0, out, '']) | 929 command_outputs.append([0, out, '']) |
935 | 930 |
936 new_calls = self.calls[num_previous_calls:] | 931 new_calls = self.calls[num_previous_calls:] |
937 self.calls = self.calls[:num_previous_calls] | 932 self.calls = self.calls[:num_previous_calls] |
938 self.calls.append(new_calls) | 933 self.calls.append(new_calls) |
939 return command_outputs | 934 return command_outputs |
| 935 |
| 936 |
| 937 class TestBaselineSetTest(unittest.TestCase): |
| 938 |
| 939 def setUp(self): |
| 940 host = MockWebKitPatch() |
| 941 host.port_factory = MockPortFactory(host) |
| 942 port = host.port_factory.get() |
| 943 base_dir = port.layout_tests_dir() |
| 944 host.filesystem.write_text_file(base_dir + '/a/x.html', '<html>') |
| 945 host.filesystem.write_text_file(base_dir + '/a/y.html', '<html>') |
| 946 host.filesystem.write_text_file(base_dir + '/a/z.html', '<html>') |
| 947 host.builders = BuilderList({ |
| 948 'MOCK Mac10.12': {'port_name': 'test-mac-mac10.12', 'specifiers': ['
Mac10.12', 'Release']}, |
| 949 'MOCK Trusty': {'port_name': 'test-linux-trusty', 'specifiers': ['Tr
usty', 'Release']}, |
| 950 'MOCK Win10': {'port_name': 'test-win-win10', 'specifiers': ['Win10'
, 'Release']}, |
| 951 }) |
| 952 self.host = host |
| 953 |
| 954 def test_add_and_iter_tests(self): |
| 955 test_baseline_set = TestBaselineSet(host=self.host) |
| 956 test_baseline_set.add('a', Build('MOCK Trusty')) |
| 957 test_baseline_set.add('a/z.html', Build('MOCK Win10')) |
| 958 self.assertEqual( |
| 959 list(test_baseline_set), |
| 960 [ |
| 961 ('a/x.html', Build(builder_name='MOCK Trusty')), |
| 962 ('a/y.html', Build(builder_name='MOCK Trusty')), |
| 963 ('a/z.html', Build(builder_name='MOCK Trusty')), |
| 964 ('a/z.html', Build(builder_name='MOCK Win10')), |
| 965 ]) |
| 966 |
| 967 def test_str_empty(self): |
| 968 test_baseline_set = TestBaselineSet(host=self.host) |
| 969 self.assertEqual(str(test_baseline_set), '<Empty TestBaselineSet>') |
| 970 |
| 971 def test_str_basic(self): |
| 972 test_baseline_set = TestBaselineSet(host=self.host) |
| 973 test_baseline_set.add('a/x.html', Build('MOCK Mac10.12')) |
| 974 test_baseline_set.add('a/x.html', Build('MOCK Win10')) |
| 975 self.assertEqual( |
| 976 str(test_baseline_set), |
| 977 ('<TestBaselineSet with:\n' |
| 978 ' a/x.html: Build(builder_name=\'MOCK Mac10.12\', build_number=Non
e)\n' |
| 979 ' a/x.html: Build(builder_name=\'MOCK Win10\', build_number=None)>
')) |
OLD | NEW |