| 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer | 7 from webkitpy.common.checkout.baselineoptimizer import BaselineOptimizer |
| 8 from webkitpy.common.checkout.scm.scm_mock import MockSCM | 8 from webkitpy.common.checkout.scm.scm_mock import MockSCM |
| 9 from webkitpy.common.host_mock import MockHost | 9 from webkitpy.common.host_mock import MockHost |
| 10 from webkitpy.common.net.buildbot_mock import MockBuilder | 10 from webkitpy.common.net.buildbot_mock import MockBuilder |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 new_expectations = self._read(self.mac_expectations_path) | 548 new_expectations = self._read(self.mac_expectations_path) |
| 549 self.assertMultiLineEqual( | 549 self.assertMultiLineEqual( |
| 550 new_expectations, "Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n") | 550 new_expectations, "Bug(x) [ Linux Mac10.10 Win ] userscripts/first-t
est.html [ Failure ]\n") |
| 551 | 551 |
| 552 | 552 |
| 553 class TestRebaseline(BaseTestCase): | 553 class TestRebaseline(BaseTestCase): |
| 554 # This command shares most of its logic with RebaselineJson, so these tests
just test what is different. | 554 # This command shares most of its logic with RebaselineJson, so these tests
just test what is different. |
| 555 | 555 |
| 556 command_constructor = Rebaseline # AKA webkit-patch rebaseline | 556 command_constructor = Rebaseline # AKA webkit-patch rebaseline |
| 557 | 557 |
| 558 def test_rebaseline(self): | 558 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 559 def disabled_test_rebaseline(self): |
| 559 self.command._builders_to_pull_from = lambda: [MockBuilder('MOCK Win7')] | 560 self.command._builders_to_pull_from = lambda: [MockBuilder('MOCK Win7')] |
| 560 | 561 |
| 561 self._write("userscripts/first-test.html", "test data") | 562 self._write("userscripts/first-test.html", "test data") |
| 562 | 563 |
| 563 self._zero_out_test_expectations() | 564 self._zero_out_test_expectations() |
| 564 self._setup_mock_builder_data() | 565 self._setup_mock_builder_data() |
| 565 | 566 |
| 566 self.tool.builders = BuilderList({ | 567 self.tool.builders = BuilderList({ |
| 567 "MOCK Win7": {"port_name": "test-mac-mac10.10", "specifiers": ["Win7
", "Release"]}, | 568 "MOCK Win7": {"port_name": "test-mac-mac10.10", "specifiers": ["Win7
", "Release"]}, |
| 568 }) | 569 }) |
| 569 self.command.execute(MockOptions(results_directory=False, optimize=False
, builders=None, | 570 self.command.execute(MockOptions(results_directory=False, optimize=False
, builders=None, |
| 570 suffixes="txt,png", verbose=True), ['us
erscripts/first-test.html'], self.tool) | 571 suffixes="txt,png", verbose=True), ['us
erscripts/first-test.html'], self.tool) |
| 571 | 572 |
| 572 calls = filter(lambda x: x != ['qmake', '-v'] and x[0] != 'perl', self.t
ool.executive.calls) | 573 calls = filter(lambda x: x != ['qmake', '-v'] and x[0] != 'perl', self.t
ool.executive.calls) |
| 573 self.assertEqual(calls, | 574 self.assertEqual(calls, |
| 574 [[['python', 'echo', 'copy-existing-baselines-internal'
, '--suffixes', 'txt,png', '--builder', 'MOCK Win7', '--test', 'userscripts/firs
t-test.html', '--verbose']], | 575 [[['python', 'echo', 'copy-existing-baselines-internal'
, '--suffixes', 'txt,png', '--builder', 'MOCK Win7', '--test', 'userscripts/firs
t-test.html', '--verbose']], |
| 575 [['python', 'echo', 'rebaseline-test-internal', '--suf
fixes', 'txt,png', '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.h
tml', '--verbose']]]) | 576 [['python', 'echo', 'rebaseline-test-internal', '--suf
fixes', 'txt,png', '--builder', 'MOCK Win7', '--test', 'userscripts/first-test.h
tml', '--verbose']]]) |
| 576 | 577 |
| 577 def test_rebaseline_directory(self): | 578 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 579 def disabled_test_rebaseline_directory(self): |
| 578 self.command._builders_to_pull_from = lambda: [MockBuilder('MOCK Win7')] | 580 self.command._builders_to_pull_from = lambda: [MockBuilder('MOCK Win7')] |
| 579 | 581 |
| 580 self._write("userscripts/first-test.html", "test data") | 582 self._write("userscripts/first-test.html", "test data") |
| 581 self._write("userscripts/second-test.html", "test data") | 583 self._write("userscripts/second-test.html", "test data") |
| 582 | 584 |
| 583 self._setup_mock_builder_data() | 585 self._setup_mock_builder_data() |
| 584 | 586 |
| 585 self.tool.builders = BuilderList({ | 587 self.tool.builders = BuilderList({ |
| 586 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "
Release"]}, | 588 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", "
Release"]}, |
| 587 }) | 589 }) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 622 |
| 621 def setUp(self): | 623 def setUp(self): |
| 622 super(TestRebaselineExpectations, self).setUp() | 624 super(TestRebaselineExpectations, self).setUp() |
| 623 self.options = MockOptions(optimize=False, builders=None, suffixes=[ | 625 self.options = MockOptions(optimize=False, builders=None, suffixes=[ |
| 624 'txt'], verbose=False, platform=None, results
_directory=None) | 626 'txt'], verbose=False, platform=None, results
_directory=None) |
| 625 | 627 |
| 626 def _write_test_file(self, port, path, contents): | 628 def _write_test_file(self, port, path, contents): |
| 627 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) | 629 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) |
| 628 self.tool.filesystem.write_text_file(abs_path, contents) | 630 self.tool.filesystem.write_text_file(abs_path, contents) |
| 629 | 631 |
| 630 def test_rebaseline_expectations(self): | 632 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 633 def disabled_test_rebaseline_expectations(self): |
| 631 self._zero_out_test_expectations() | 634 self._zero_out_test_expectations() |
| 632 | 635 |
| 633 self.tool.executive = MockExecutive2() | 636 self.tool.executive = MockExecutive2() |
| 634 | 637 |
| 635 def builder_data(): | 638 def builder_data(): |
| 636 self.command._builder_data['MOCK Mac10.11'] = self.command._builder_
data['MOCK Mac10.10'] = LayoutTestResults.results_from_string("""ADD_RESULTS({ | 639 self.command._builder_data['MOCK Mac10.11'] = self.command._builder_
data['MOCK Mac10.10'] = LayoutTestResults.results_from_string("""ADD_RESULTS({ |
| 637 "tests": { | 640 "tests": { |
| 638 "userscripts": { | 641 "userscripts": { |
| 639 "another-test.html": { | 642 "another-test.html": { |
| 640 "expected": "PASS", | 643 "expected": "PASS", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/another
-test.html'], | 685 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/another
-test.html'], |
| 683 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 686 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 684 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/another
-test.html'], | 687 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/another
-test.html'], |
| 685 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 688 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', |
| 686 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.
svg'], | 689 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.
svg'], |
| 687 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 690 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', |
| 688 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.
svg'], | 691 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.
svg'], |
| 689 ], | 692 ], |
| 690 ]) | 693 ]) |
| 691 | 694 |
| 692 def test_rebaseline_expectations_reftests(self): | 695 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 696 def disabled_test_rebaseline_expectations_reftests(self): |
| 693 self._zero_out_test_expectations() | 697 self._zero_out_test_expectations() |
| 694 | 698 |
| 695 self.tool.executive = MockExecutive2() | 699 self.tool.executive = MockExecutive2() |
| 696 | 700 |
| 697 def builder_data(): | 701 def builder_data(): |
| 698 self.command._builder_data['MOCK Mac10.10'] = self.command._builder_
data['MOCK Mac10.11'] = LayoutTestResults.results_from_string("""ADD_RESULTS({ | 702 self.command._builder_data['MOCK Mac10.10'] = self.command._builder_
data['MOCK Mac10.11'] = LayoutTestResults.results_from_string("""ADD_RESULTS({ |
| 699 "tests": { | 703 "tests": { |
| 700 "userscripts": { | 704 "userscripts": { |
| 701 "reftest-text.html": { | 705 "reftest-text.html": { |
| 702 "expected": "PASS", | 706 "expected": "PASS", |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/reftest
-text.html'], | 746 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/reftest
-text.html'], |
| 743 ], | 747 ], |
| 744 [ | 748 [ |
| 745 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 749 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 746 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/reftest
-text.html'], | 750 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/reftest
-text.html'], |
| 747 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 751 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 748 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/reftest
-text.html'], | 752 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/reftest
-text.html'], |
| 749 ], | 753 ], |
| 750 ]) | 754 ]) |
| 751 | 755 |
| 752 def test_rebaseline_expectations_noop(self): | 756 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 757 def disabled_test_rebaseline_expectations_noop(self): |
| 753 self._zero_out_test_expectations() | 758 self._zero_out_test_expectations() |
| 754 | 759 |
| 755 oc = OutputCapture() | 760 oc = OutputCapture() |
| 756 try: | 761 try: |
| 757 oc.capture_output() | 762 oc.capture_output() |
| 758 self.command.execute(self.options, [], self.tool) | 763 self.command.execute(self.options, [], self.tool) |
| 759 finally: | 764 finally: |
| 760 _, _, logs = oc.restore_output() | 765 _, _, logs = oc.restore_output() |
| 761 self.assertEqual(self.tool.filesystem.written_files, {}) | 766 self.assertEqual(self.tool.filesystem.written_files, {}) |
| 762 self.assertEqual(logs, 'Did not find any tests marked Rebaseline.\n'
) | 767 self.assertEqual(logs, 'Did not find any tests marked Rebaseline.\n'
) |
| 763 | 768 |
| 764 def disabled_test_overrides_are_included_correctly(self): | 769 def disabled_test_overrides_are_included_correctly(self): |
| 765 # This tests that the any tests marked as REBASELINE in the overrides ar
e found, but | 770 # This tests that the any tests marked as REBASELINE in the overrides ar
e found, but |
| 766 # that the overrides do not get written into the main file. | 771 # that the overrides do not get written into the main file. |
| 767 self._zero_out_test_expectations() | 772 self._zero_out_test_expectations() |
| 768 | 773 |
| 769 self._write(self.mac_expectations_path, '') | 774 self._write(self.mac_expectations_path, '') |
| 770 self.mac_port.expectations_dict = lambda: { | 775 self.mac_port.expectations_dict = lambda: { |
| 771 self.mac_expectations_path: '', | 776 self.mac_expectations_path: '', |
| 772 'overrides': ('Bug(x) userscripts/another-test.html [ Failure Rebase
line ]\n' | 777 'overrides': ('Bug(x) userscripts/another-test.html [ Failure Rebase
line ]\n' |
| 773 'Bug(y) userscripts/test.html [ Crash ]\n')} | 778 'Bug(y) userscripts/test.html [ Crash ]\n')} |
| 774 self._write('/userscripts/another-test.html', '') | 779 self._write('/userscripts/another-test.html', '') |
| 775 | 780 |
| 776 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), { | 781 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), { |
| 777 'userscripts/another-test.html': set(['png', 'txt',
'wav'])}) | 782 'userscripts/another-test.html': set(['png', 'txt',
'wav'])}) |
| 778 self.assertEqual(self._read(self.mac_expectations_path), '') | 783 self.assertEqual(self._read(self.mac_expectations_path), '') |
| 779 | 784 |
| 780 def test_rebaseline_without_other_expectations(self): | 785 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 786 def disabled_test_rebaseline_without_other_expectations(self): |
| 781 self._write("userscripts/another-test.html", "Dummy test contents") | 787 self._write("userscripts/another-test.html", "Dummy test contents") |
| 782 self._write(self.mac_expectations_path, "Bug(x) userscripts/another-test
.html [ Rebaseline ]\n") | 788 self._write(self.mac_expectations_path, "Bug(x) userscripts/another-test
.html [ Rebaseline ]\n") |
| 783 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), { | 789 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), { |
| 784 'userscripts/another-test.html': ('png', 'wav', 'tx
t')}) | 790 'userscripts/another-test.html': ('png', 'wav', 'tx
t')}) |
| 785 | 791 |
| 786 def test_rebaseline_test_passes_everywhere(self): | 792 # TODO(crbug.com/574272) - Reenable this after the bug is fixed. |
| 793 def disabled_test_rebaseline_test_passes_everywhere(self): |
| 787 test_port = self.tool.port_factory.get('test') | 794 test_port = self.tool.port_factory.get('test') |
| 788 | 795 |
| 789 old_builder_data = self.command.builder_data | 796 old_builder_data = self.command.builder_data |
| 790 | 797 |
| 791 def builder_data(): | 798 def builder_data(): |
| 792 self.command._builder_data['MOCK Mac10.10'] = self.command._builder_
data['MOCK Mac10.11'] = LayoutTestResults.results_from_string("""ADD_RESULTS({ | 799 self.command._builder_data['MOCK Mac10.10'] = self.command._builder_
data['MOCK Mac10.11'] = LayoutTestResults.results_from_string("""ADD_RESULTS({ |
| 793 "tests": { | 800 "tests": { |
| 794 "fast": { | 801 "fast": { |
| 795 "dom": { | 802 "dom": { |
| 796 "prototype-taco.html": { | 803 "prototype-taco.html": { |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', RIETV
ELD_REFRESH_TOKEN], | 1428 ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', RIETV
ELD_REFRESH_TOKEN], |
| 1422 ['git', 'pull'], | 1429 ['git', 'pull'], |
| 1423 ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', R
IETVELD_REFRESH_TOKEN], | 1430 ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', R
IETVELD_REFRESH_TOKEN], |
| 1424 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv
eldissue'], | 1431 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv
eldissue'], |
| 1425 ], | 1432 ], |
| 1426 auth_refresh_token_json=RIETVELD_REFRESH_TOKEN) | 1433 auth_refresh_token_json=RIETVELD_REFRESH_TOKEN) |
| 1427 | 1434 |
| 1428 def test_execute_with_dry_run(self): | 1435 def test_execute_with_dry_run(self): |
| 1429 self._basic_execute_test([], dry_run=True) | 1436 self._basic_execute_test([], dry_run=True) |
| 1430 self.assertEqual(self.tool.scm().local_commits(), []) | 1437 self.assertEqual(self.tool.scm().local_commits(), []) |
| OLD | NEW |