| 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 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 class TestAbstractParallelRebaselineCommand(BaseTestCase): | 322 class TestAbstractParallelRebaselineCommand(BaseTestCase): |
| 323 command_constructor = AbstractParallelRebaselineCommand | 323 command_constructor = AbstractParallelRebaselineCommand |
| 324 | 324 |
| 325 def test_builders_to_fetch_from(self): | 325 def test_builders_to_fetch_from(self): |
| 326 builders_to_fetch = self.command._builders_to_fetch_from( | 326 builders_to_fetch = self.command._builders_to_fetch_from( |
| 327 ['MOCK Win10', 'MOCK Win7 (dbg)(1)', 'MOCK Win7 (dbg)(2)', 'MOCK Win
7']) | 327 ['MOCK Win10', 'MOCK Win7 (dbg)(1)', 'MOCK Win7 (dbg)(2)', 'MOCK Win
7']) |
| 328 self.assertEqual(builders_to_fetch, ['MOCK Win7', 'MOCK Win10']) | 328 self.assertEqual(builders_to_fetch, ['MOCK Win7', 'MOCK Win10']) |
| 329 | 329 |
| 330 def test_all_baseline_paths(self): | 330 def test_all_baseline_paths(self): |
| 331 test_prefix_list = { | 331 test_prefix_list = { |
| 332 'passes/text.html': { | 332 'passes/text.html': [ |
| 333 Build('MOCK Win7'): ('txt', 'png'), | 333 Build('MOCK Win7'), |
| 334 Build('MOCK Win10'): ('txt',), | 334 Build('MOCK Win10'), |
| 335 } | 335 ] |
| 336 } | 336 } |
| 337 # pylint: disable=protected-access | 337 # pylint: disable=protected-access |
| 338 baseline_paths = self.command._all_baseline_paths(test_prefix_list) | 338 baseline_paths = self.command._all_baseline_paths(test_prefix_list) |
| 339 self.assertEqual(baseline_paths, [ | 339 self.assertEqual(baseline_paths, [ |
| 340 '/test.checkout/LayoutTests/passes/text-expected.png', | 340 '/test.checkout/LayoutTests/passes/text-expected.png', |
| 341 '/test.checkout/LayoutTests/passes/text-expected.txt', | 341 '/test.checkout/LayoutTests/passes/text-expected.txt', |
| 342 '/test.checkout/LayoutTests/passes/text-expected.wav', |
| 343 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.png', |
| 342 '/test.checkout/LayoutTests/platform/test-win-win10/passes/text-expe
cted.txt', | 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.wav', |
| 343 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.png', | 346 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.png', |
| 344 '/test.checkout/LayoutTests/platform/test-win-win7/passes/text-expec
ted.txt', | 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.wav', |
| 345 ]) | 349 ]) |
| 346 | 350 |
| 347 def test_remove_all_pass_testharness_baselines(self): | 351 def test_remove_all_pass_testharness_baselines(self): |
| 348 self.tool.filesystem.write_text_file( | 352 self.tool.filesystem.write_text_file( |
| 349 '/test.checkout/LayoutTests/passes/text-expected.txt', | 353 '/test.checkout/LayoutTests/passes/text-expected.txt', |
| 350 ('This is a testharness.js-based test.\n' | 354 ('This is a testharness.js-based test.\n' |
| 351 'PASS: foo\n' | 355 'PASS: foo\n' |
| 352 'Harness: the test ran to completion.\n')) | 356 'Harness: the test ran to completion.\n')) |
| 353 test_prefix_list = { | 357 test_prefix_list = { |
| 354 'passes/text.html': { | 358 'passes/text.html': [ |
| 355 Build('MOCK Win7'): ('txt', 'png'), | 359 Build('MOCK Win7'), |
| 356 Build('MOCK Win10'): ('txt',), | 360 Build('MOCK Win10'), |
| 357 } | 361 ] |
| 358 } | 362 } |
| 359 self.command._remove_all_pass_testharness_baselines(test_prefix_list) | 363 self.command._remove_all_pass_testharness_baselines(test_prefix_list) |
| 360 self.assertFalse(self.tool.filesystem.exists( | 364 self.assertFalse(self.tool.filesystem.exists( |
| 361 '/test.checkout/LayoutTests/passes/text-expected.txt')) | 365 '/test.checkout/LayoutTests/passes/text-expected.txt')) |
| 362 | 366 |
| 363 | 367 |
| 364 class TestRebaselineJson(BaseTestCase): | 368 class TestRebaselineJson(BaseTestCase): |
| 365 command_constructor = RebaselineJson | 369 command_constructor = RebaselineJson |
| 366 | 370 |
| 367 def setUp(self): | 371 def setUp(self): |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 'expected': 'FAIL', | 698 'expected': 'FAIL', |
| 695 'actual': 'IMAGE+TEXT' | 699 'actual': 'IMAGE+TEXT' |
| 696 } | 700 } |
| 697 } | 701 } |
| 698 } | 702 } |
| 699 })) | 703 })) |
| 700 | 704 |
| 701 self._write('userscripts/another-test.html', 'Dummy test contents') | 705 self._write('userscripts/another-test.html', 'Dummy test contents') |
| 702 self._write('userscripts/images.svg', 'Dummy test contents') | 706 self._write('userscripts/images.svg', 'Dummy test contents') |
| 703 self.command._tests_to_rebaseline = lambda port: { | 707 self.command._tests_to_rebaseline = lambda port: { |
| 704 'userscripts/another-test.html': set(['txt']), | 708 'userscripts/another-test.html', |
| 705 'userscripts/images.svg': set(['png']), | 709 'userscripts/images.svg', |
| 706 'userscripts/not-actually-failing.html': set(['txt', 'png', 'wav']), | 710 'userscripts/not-actually-failing.html', |
| 707 } | 711 } |
| 708 | 712 |
| 709 self.command.execute(self.options(), [], self.tool) | 713 self.command.execute(self.options(), [], self.tool) |
| 710 | 714 |
| 711 self.assertEqual(self.tool.executive.calls, [ | 715 self.assertEqual(self.tool.executive.calls, [ |
| 712 [ | 716 [ |
| 713 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt', | 717 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt', |
| 714 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/another-te
st.html'], | 718 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/another-te
st.html'], |
| 715 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt', | 719 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt', |
| 716 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/another-te
st.html'], | 720 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/another-te
st.html'], |
| 717 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'png', | 721 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt,png', |
| 718 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.svg
'], | 722 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.svg
'], |
| 719 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'png', | 723 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix
es', 'txt,png', |
| 720 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.svg
'], | 724 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.svg
'], |
| 721 ], | 725 ], |
| 722 [ | 726 [ |
| 723 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 727 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 724 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/another-te
st.html'], | 728 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/another-te
st.html'], |
| 725 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 729 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 726 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/another-te
st.html'], | 730 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/another-te
st.html'], |
| 727 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 731 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t,png', |
| 728 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.svg
'], | 732 '--builder', 'MOCK Mac10.10', '--test', 'userscripts/images.svg
'], |
| 729 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 733 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t,png', |
| 730 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.svg
'], | 734 '--builder', 'MOCK Mac10.11', '--test', 'userscripts/images.svg
'], |
| 731 ], | 735 ], |
| 732 ]) | 736 ]) |
| 733 | 737 |
| 734 def test_rebaseline_expectations_reftests(self): | 738 def test_rebaseline_expectations_reftests(self): |
| 735 self._zero_out_test_expectations() | 739 self._zero_out_test_expectations() |
| 736 | 740 |
| 737 self.tool.executive = MockExecutive() | 741 self.tool.executive = MockExecutive() |
| 738 | 742 |
| 739 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: | 743 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 'Bug(y) userscripts/test.html [ Crash ]\n')} | 811 'Bug(y) userscripts/test.html [ Crash ]\n')} |
| 808 self._write('/userscripts/another-test.html', '') | 812 self._write('/userscripts/another-test.html', '') |
| 809 | 813 |
| 810 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), | 814 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), |
| 811 {'userscripts/another-test.html': set(['png', 'txt'
, 'wav'])}) | 815 {'userscripts/another-test.html': set(['png', 'txt'
, 'wav'])}) |
| 812 self.assertEqual(self._read(self.mac_expectations_path), '') | 816 self.assertEqual(self._read(self.mac_expectations_path), '') |
| 813 | 817 |
| 814 def test_rebaseline_without_other_expectations(self): | 818 def test_rebaseline_without_other_expectations(self): |
| 815 self._write('userscripts/another-test.html', 'Dummy test contents') | 819 self._write('userscripts/another-test.html', 'Dummy test contents') |
| 816 self._write(self.mac_expectations_path, 'Bug(x) userscripts/another-test
.html [ Rebaseline ]\n') | 820 self._write(self.mac_expectations_path, 'Bug(x) userscripts/another-test
.html [ Rebaseline ]\n') |
| 817 self.assertDictEqual(self.command._tests_to_rebaseline(self.mac_port), | 821 self.assertEqual(self.command._tests_to_rebaseline(self.mac_port), ['use
rscripts/another-test.html']) |
| 818 {'userscripts/another-test.html': ('png', 'wav', 't
xt')}) | |
| 819 | 822 |
| 820 def test_rebaseline_test_passes_everywhere(self): | 823 def test_rebaseline_test_passes_everywhere(self): |
| 821 test_port = self.tool.port_factory.get('test') | 824 test_port = self.tool.port_factory.get('test') |
| 822 | 825 |
| 823 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: | 826 for builder in ['MOCK Mac10.10', 'MOCK Mac10.11']: |
| 824 self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ | 827 self.tool.buildbot.set_results(Build(builder), LayoutTestResults({ |
| 825 'tests': { | 828 'tests': { |
| 826 'fast': { | 829 'fast': { |
| 827 'dom': { | 830 'dom': { |
| 828 'prototype-taco.html': { | 831 'prototype-taco.html': { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 for cmd_line, cwd in commands: | 930 for cmd_line, cwd in commands: |
| 928 out = self.run_command(cmd_line, cwd=cwd) | 931 out = self.run_command(cmd_line, cwd=cwd) |
| 929 if 'rebaseline-test-internal' in cmd_line: | 932 if 'rebaseline-test-internal' in cmd_line: |
| 930 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) | 933 out = '{"remove-lines": [{"test": "%s", "builder": "%s"}]}\n' %
(cmd_line[8], cmd_line[6]) |
| 931 command_outputs.append([0, out, '']) | 934 command_outputs.append([0, out, '']) |
| 932 | 935 |
| 933 new_calls = self.calls[num_previous_calls:] | 936 new_calls = self.calls[num_previous_calls:] |
| 934 self.calls = self.calls[:num_previous_calls] | 937 self.calls = self.calls[:num_previous_calls] |
| 935 self.calls.append(new_calls) | 938 self.calls.append(new_calls) |
| 936 return command_outputs | 939 return command_outputs |
| OLD | NEW |