| 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, MockExecutive2 | 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.tool.commands.rebaseline import ( | 13 from webkitpy.tool.commands.rebaseline import ( |
| 14 AbstractParallelRebaselineCommand, CopyExistingBaselinesInternal, | 14 AbstractParallelRebaselineCommand, CopyExistingBaselinesInternal, |
| 15 Rebaseline, RebaselineExpectations, RebaselineJson, RebaselineTest | 15 Rebaseline, RebaselineExpectations, RebaselineJson, RebaselineTest |
| 16 ) | 16 ) |
| 17 from webkitpy.tool.mock_tool import MockWebKitPatch | 17 from webkitpy.tool.mock_tool import MockWebKitPatch |
| 18 | 18 |
| 19 | 19 |
| 20 # pylint: disable=protected-access | 20 # pylint: disable=protected-access |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 port.layout_tests_dir(), | 142 port.layout_tests_dir(), |
| 143 'platform/test-mac-mac10.11/failures/expected/image-expected.txt
')), | 143 'platform/test-mac-mac10.11/failures/expected/image-expected.txt
')), |
| 144 'original mac10.11 result') | 144 'original mac10.11 result') |
| 145 self.assertEqual( | 145 self.assertEqual( |
| 146 self._read(self.tool.filesystem.join( | 146 self._read(self.tool.filesystem.join( |
| 147 port.layout_tests_dir(), | 147 port.layout_tests_dir(), |
| 148 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
')), | 148 'platform/test-mac-mac10.10/failures/expected/image-expected.txt
')), |
| 149 'original mac10.11 result') | 149 'original mac10.11 result') |
| 150 | 150 |
| 151 def test_copying_overwritten_baseline_to_multiple_locations(self): | 151 def test_copying_overwritten_baseline_to_multiple_locations(self): |
| 152 self.tool.executive = MockExecutive2() | 152 self.tool.executive = MockExecutive() |
| 153 | 153 |
| 154 def test_copy_baseline_win7_to_linux_trusty(self): | 154 def test_copy_baseline_win7_to_linux_trusty(self): |
| 155 port = self.tool.port_factory.get('test-win-win7') | 155 port = self.tool.port_factory.get('test-win-win7') |
| 156 self._write( | 156 self._write( |
| 157 self.tool.filesystem.join( | 157 self.tool.filesystem.join( |
| 158 port.layout_tests_dir(), | 158 port.layout_tests_dir(), |
| 159 'platform/test-win-win7/failures/expected/image-expected.txt'), | 159 'platform/test-win-win7/failures/expected/image-expected.txt'), |
| 160 'original win7 result') | 160 'original win7 result') |
| 161 self.assertFalse(self.tool.filesystem.exists( | 161 self.assertFalse(self.tool.filesystem.exists( |
| 162 self.tool.filesystem.join( | 162 self.tool.filesystem.join( |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 def test_rebaseline_reftest(self): | 292 def test_rebaseline_reftest(self): |
| 293 self._write("userscripts/another-test.html", "test data") | 293 self._write("userscripts/another-test.html", "test data") |
| 294 self._write("userscripts/another-test-expected.html", "generic result") | 294 self._write("userscripts/another-test-expected.html", "generic result") |
| 295 OutputCapture().assert_outputs( | 295 OutputCapture().assert_outputs( |
| 296 self, self.command._rebaseline_test_and_update_expectations, args=[s
elf.options(suffixes='png')], | 296 self, self.command._rebaseline_test_and_update_expectations, args=[s
elf.options(suffixes='png')], |
| 297 expected_logs="Cannot rebaseline image result for reftest: userscrip
ts/another-test.html\n") | 297 expected_logs="Cannot rebaseline image result for reftest: userscrip
ts/another-test.html\n") |
| 298 self.assertDictEqual(self.command.expectation_line_changes.to_dict(), {'
remove-lines': []}) | 298 self.assertDictEqual(self.command.expectation_line_changes.to_dict(), {'
remove-lines': []}) |
| 299 | 299 |
| 300 def test_rebaseline_test_internal_with_port_that_lacks_buildbot(self): | 300 def test_rebaseline_test_internal_with_port_that_lacks_buildbot(self): |
| 301 self.tool.executive = MockExecutive2() | 301 self.tool.executive = MockExecutive() |
| 302 | 302 |
| 303 port = self.tool.port_factory.get('test-win-win7') | 303 port = self.tool.port_factory.get('test-win-win7') |
| 304 self._write( | 304 self._write( |
| 305 port.host.filesystem.join( | 305 port.host.filesystem.join( |
| 306 port.layout_tests_dir(), | 306 port.layout_tests_dir(), |
| 307 'platform/test-win-win10/failures/expected/image-expected.txt'), | 307 'platform/test-win-win10/failures/expected/image-expected.txt'), |
| 308 'original win10 result') | 308 'original win10 result') |
| 309 | 309 |
| 310 oc = OutputCapture() | 310 oc = OutputCapture() |
| 311 try: | 311 try: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 self.command._remove_all_pass_testharness_baselines(test_prefix_list) | 374 self.command._remove_all_pass_testharness_baselines(test_prefix_list) |
| 375 self.assertFalse(self.tool.filesystem.exists( | 375 self.assertFalse(self.tool.filesystem.exists( |
| 376 '/test.checkout/LayoutTests/passes/text-expected.txt')) | 376 '/test.checkout/LayoutTests/passes/text-expected.txt')) |
| 377 | 377 |
| 378 | 378 |
| 379 class TestRebaselineJson(BaseTestCase): | 379 class TestRebaselineJson(BaseTestCase): |
| 380 command_constructor = RebaselineJson | 380 command_constructor = RebaselineJson |
| 381 | 381 |
| 382 def setUp(self): | 382 def setUp(self): |
| 383 super(TestRebaselineJson, self).setUp() | 383 super(TestRebaselineJson, self).setUp() |
| 384 self.tool.executive = MockExecutive2() | 384 self.tool.executive = MockExecutive() |
| 385 | 385 |
| 386 def tearDown(self): | 386 def tearDown(self): |
| 387 super(TestRebaselineJson, self).tearDown() | 387 super(TestRebaselineJson, self).tearDown() |
| 388 | 388 |
| 389 @staticmethod | 389 @staticmethod |
| 390 def options(**kwargs): | 390 def options(**kwargs): |
| 391 return optparse.Values(dict({ | 391 return optparse.Values(dict({ |
| 392 'optimize': True, | 392 'optimize': True, |
| 393 'verbose': True, | 393 'verbose': True, |
| 394 'results_directory': None | 394 'results_directory': None |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.pn
g', | 499 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.pn
g', |
| 500 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.tx
t', | 500 '/mock-checkout/third_party/WebKit/LayoutTests/x/foo-expected.tx
t', |
| 501 ]) | 501 ]) |
| 502 | 502 |
| 503 | 503 |
| 504 class TestRebaselineJsonUpdatesExpectationsFiles(BaseTestCase): | 504 class TestRebaselineJsonUpdatesExpectationsFiles(BaseTestCase): |
| 505 command_constructor = RebaselineJson | 505 command_constructor = RebaselineJson |
| 506 | 506 |
| 507 def setUp(self): | 507 def setUp(self): |
| 508 super(TestRebaselineJsonUpdatesExpectationsFiles, self).setUp() | 508 super(TestRebaselineJsonUpdatesExpectationsFiles, self).setUp() |
| 509 self.tool.executive = MockExecutive2() | 509 self.tool.executive = MockExecutive() |
| 510 | 510 |
| 511 def mock_run_command(*args, **kwargs): # pylint: disable=unused-argumen
t | 511 def mock_run_command(*args, **kwargs): # pylint: disable=unused-argumen
t |
| 512 return '{"add": [], "remove-lines": [{"test": "userscripts/first-tes
t.html", "builder": "MOCK Mac10.11"}]}\n' | 512 return '{"add": [], "remove-lines": [{"test": "userscripts/first-tes
t.html", "builder": "MOCK Mac10.11"}]}\n' |
| 513 self.tool.executive.run_command = mock_run_command | 513 self.tool.executive.run_command = mock_run_command |
| 514 | 514 |
| 515 @staticmethod | 515 @staticmethod |
| 516 def options(): | 516 def options(): |
| 517 return optparse.Values({ | 517 return optparse.Values({ |
| 518 'optimize': False, | 518 'optimize': False, |
| 519 'verbose': True, | 519 'verbose': True, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 'results_directory': None | 688 'results_directory': None |
| 689 }) | 689 }) |
| 690 | 690 |
| 691 def _write_test_file(self, port, path, contents): | 691 def _write_test_file(self, port, path, contents): |
| 692 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) | 692 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) |
| 693 self.tool.filesystem.write_text_file(abs_path, contents) | 693 self.tool.filesystem.write_text_file(abs_path, contents) |
| 694 | 694 |
| 695 def test_rebaseline_expectations(self): | 695 def test_rebaseline_expectations(self): |
| 696 self._zero_out_test_expectations() | 696 self._zero_out_test_expectations() |
| 697 | 697 |
| 698 self.tool.executive = MockExecutive2() | 698 self.tool.executive = MockExecutive() |
| 699 | 699 |
| 700 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: | 700 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: |
| 701 self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ | 701 self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ |
| 702 "tests": { | 702 "tests": { |
| 703 "userscripts": { | 703 "userscripts": { |
| 704 "another-test.html": { | 704 "another-test.html": { |
| 705 "expected": "PASS", | 705 "expected": "PASS", |
| 706 "actual": "PASS TEXT" | 706 "actual": "PASS TEXT" |
| 707 }, | 707 }, |
| 708 "images.svg": { | 708 "images.svg": { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 742 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', |
| 743 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.svg
'], | 743 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.svg
'], |
| 744 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 744 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', |
| 745 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.svg
'], | 745 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.svg
'], |
| 746 ], | 746 ], |
| 747 ]) | 747 ]) |
| 748 | 748 |
| 749 def test_rebaseline_expectations_reftests(self): | 749 def test_rebaseline_expectations_reftests(self): |
| 750 self._zero_out_test_expectations() | 750 self._zero_out_test_expectations() |
| 751 | 751 |
| 752 self.tool.executive = MockExecutive2() | 752 self.tool.executive = MockExecutive() |
| 753 | 753 |
| 754 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: | 754 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: |
| 755 self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ | 755 self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ |
| 756 "tests": { | 756 "tests": { |
| 757 "userscripts": { | 757 "userscripts": { |
| 758 "reftest-text.html": { | 758 "reftest-text.html": { |
| 759 "expected": "PASS", | 759 "expected": "PASS", |
| 760 "actual": "TEXT" | 760 "actual": "TEXT" |
| 761 }, | 761 }, |
| 762 "reftest-image.html": { | 762 "reftest-image.html": { |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 for cmd_line, cwd in commands: | 942 for cmd_line, cwd in commands: |
| 943 out = self.run_command(cmd_line, cwd=cwd) | 943 out = self.run_command(cmd_line, cwd=cwd) |
| 944 if 'rebaseline-test-internal' in cmd_line: | 944 if 'rebaseline-test-internal' in cmd_line: |
| 945 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) | 945 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) |
| 946 command_outputs.append([0, out, '']) | 946 command_outputs.append([0, out, '']) |
| 947 | 947 |
| 948 new_calls = self.calls[num_previous_calls:] | 948 new_calls = self.calls[num_previous_calls:] |
| 949 self.calls = self.calls[:num_previous_calls] | 949 self.calls = self.calls[:num_previous_calls] |
| 950 self.calls.append(new_calls) | 950 self.calls.append(new_calls) |
| 951 return command_outputs | 951 return command_outputs |
| OLD | NEW |