| 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.net.buildbot_mock import MockBuilder | 7 from webkitpy.common.net.buildbot_mock import MockBuilder |
| 8 from webkitpy.common.net.layouttestresults import LayoutTestResults | 8 from webkitpy.common.net.layouttestresults import LayoutTestResults |
| 9 from webkitpy.common.system.executive_mock import MockExecutive | 9 from webkitpy.common.system.executive_mock import MockExecutive |
| 10 from webkitpy.common.system.executive_mock import MockExecutive2 | 10 from webkitpy.common.system.executive_mock import MockExecutive2 |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', | 843 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t', |
| 844 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text.
html'], | 844 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text.
html'], |
| 845 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t,png', | 845 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx
t,png', |
| 846 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text-
and-image.html'], | 846 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text-
and-image.html'], |
| 847 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', | 847 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn
g', |
| 848 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-image
.html'], | 848 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-image
.html'], |
| 849 ] | 849 ] |
| 850 ]) | 850 ]) |
| 851 | 851 |
| 852 | 852 |
| 853 class TestOptimizeBaselines(BaseTestCase): | |
| 854 command_constructor = OptimizeBaselines | |
| 855 | |
| 856 def _write_test_file(self, port, path, contents): | |
| 857 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) | |
| 858 self.tool.filesystem.write_text_file(abs_path, contents) | |
| 859 | |
| 860 def setUp(self): | |
| 861 super(TestOptimizeBaselines, self).setUp() | |
| 862 | |
| 863 def test_modify_scm(self): | |
| 864 test_port = self.tool.port_factory.get('test') | |
| 865 self._write_test_file(test_port, 'another/test.html', "Dummy test conten
ts") | |
| 866 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes
t-expected.txt', "result A") | |
| 867 self._write_test_file(test_port, 'another/test-expected.txt', "result A"
) | |
| 868 | |
| 869 OutputCapture().assert_outputs(self, self.command.execute, args=[ | |
| 870 MockOptions(suffixes='txt', no_modify_scm=False, platform='test-mac-
mac10.10'), | |
| 871 ['another/test.html'], | |
| 872 self.tool, | |
| 873 ], expected_stdout='{"add": [], "remove-lines": [], "delete": []}\n') | |
| 874 | |
| 875 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 876 test_port.layout_tests_dir(), 'platform/test-mac-mac10.10/another/te
st-expected.txt'))) | |
| 877 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 878 test_port.layout_tests_dir(), 'another/test-expected.txt'))) | |
| 879 | |
| 880 def test_no_modify_scm(self): | |
| 881 test_port = self.tool.port_factory.get('test') | |
| 882 self._write_test_file(test_port, 'another/test.html', "Dummy test conten
ts") | |
| 883 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes
t-expected.txt', "result A") | |
| 884 self._write_test_file(test_port, 'another/test-expected.txt', "result A"
) | |
| 885 | |
| 886 OutputCapture().assert_outputs(self, self.command.execute, args=[ | |
| 887 MockOptions(suffixes='txt', no_modify_scm=True, platform='test-mac-m
ac10.10'), | |
| 888 ['another/test.html'], | |
| 889 self.tool, | |
| 890 ], expected_stdout='{"add": [], "remove-lines": [], "delete": ["/test.ch
eckout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.txt"]}\n') | |
| 891 | |
| 892 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 893 test_port.layout_tests_dir(), 'platform/mac/another/test-expected.tx
t'))) | |
| 894 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 895 test_port.layout_tests_dir(), 'another/test-expected.txt'))) | |
| 896 | |
| 897 def test_optimize_all_suffixes_by_default(self): | |
| 898 test_port = self.tool.port_factory.get('test') | |
| 899 self._write_test_file(test_port, 'another/test.html', "Dummy test conten
ts") | |
| 900 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes
t-expected.txt', "result A") | |
| 901 self._write_test_file(test_port, 'platform/test-mac-mac10.10/another/tes
t-expected.png', "result A png") | |
| 902 self._write_test_file(test_port, 'another/test-expected.txt', "result A"
) | |
| 903 self._write_test_file(test_port, 'another/test-expected.png', "result A
png") | |
| 904 | |
| 905 try: | |
| 906 oc = OutputCapture() | |
| 907 oc.capture_output() | |
| 908 self.command.execute(MockOptions(suffixes='txt,wav,png', no_modify_s
cm=True, platform='test-mac-mac10.10'), | |
| 909 ['another/test.html'], | |
| 910 self.tool) | |
| 911 finally: | |
| 912 out, _, _ = oc.restore_output() | |
| 913 | |
| 914 self.assertEquals(out, '{"add": [], "remove-lines": [], "delete": ["/tes
t.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.txt", "/
test.checkout/LayoutTests/platform/test-mac-mac10.10/another/test-expected.png"]
}\n') | |
| 915 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 916 test_port.layout_tests_dir(), 'platform/mac/another/test-expected.tx
t'))) | |
| 917 self.assertFalse(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 918 test_port.layout_tests_dir(), 'platform/mac/another/test-expected.pn
g'))) | |
| 919 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 920 test_port.layout_tests_dir(), 'another/test-expected.txt'))) | |
| 921 self.assertTrue(self.tool.filesystem.exists(self.tool.filesystem.join( | |
| 922 test_port.layout_tests_dir(), 'another/test-expected.png'))) | |
| 923 | |
| 924 | |
| 925 class TestAutoRebaseline(BaseTestCase): | 853 class TestAutoRebaseline(BaseTestCase): |
| 926 command_constructor = AutoRebaseline | 854 command_constructor = AutoRebaseline |
| 927 | 855 |
| 928 def _write_test_file(self, port, path, contents): | 856 def _write_test_file(self, port, path, contents): |
| 929 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) | 857 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) |
| 930 self.tool.filesystem.write_text_file(abs_path, contents) | 858 self.tool.filesystem.write_text_file(abs_path, contents) |
| 931 | 859 |
| 932 def _execute_command_with_mock_options(self, auth_refresh_token_json=None, c
ommit_author=None, dry_run=False): | 860 def _execute_command_with_mock_options(self, auth_refresh_token_json=None, c
ommit_author=None, dry_run=False): |
| 933 self.command.execute( | 861 self.command.execute( |
| 934 MockOptions(optimize=True, verbose=False, results_directory=False, | 862 MockOptions(optimize=True, verbose=False, results_directory=False, |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', RIETV
ELD_REFRESH_TOKEN], | 1363 ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', RIETV
ELD_REFRESH_TOKEN], |
| 1436 ['git', 'pull'], | 1364 ['git', 'pull'], |
| 1437 ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', R
IETVELD_REFRESH_TOKEN], | 1365 ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', R
IETVELD_REFRESH_TOKEN], |
| 1438 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv
eldissue'], | 1366 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv
eldissue'], |
| 1439 ], | 1367 ], |
| 1440 auth_refresh_token_json=RIETVELD_REFRESH_TOKEN) | 1368 auth_refresh_token_json=RIETVELD_REFRESH_TOKEN) |
| 1441 | 1369 |
| 1442 def test_execute_with_dry_run(self): | 1370 def test_execute_with_dry_run(self): |
| 1443 self._basic_execute_test([], dry_run=True) | 1371 self._basic_execute_test([], dry_run=True) |
| 1444 self.assertEqual(self.tool.scm().local_commits(), []) | 1372 self.assertEqual(self.tool.scm().local_commits(), []) |
| OLD | NEW |