Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py

Issue 2191423003: Extract AutoRebaseline out of rebaseline.py. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.layouttestresults import LayoutTestResults 7 from webkitpy.common.net.layouttestresults import LayoutTestResults
8 from webkitpy.common.net.rietveld import Build
8 from webkitpy.common.system.executive_mock import MockExecutive 9 from webkitpy.common.system.executive_mock import MockExecutive
9 from webkitpy.common.system.executive_mock import MockExecutive2 10 from webkitpy.common.system.executive_mock import MockExecutive2
10 from webkitpy.common.system.outputcapture import OutputCapture 11 from webkitpy.common.system.outputcapture import OutputCapture
11 from webkitpy.layout_tests.builder_list import BuilderList 12 from webkitpy.layout_tests.builder_list import BuilderList
12 from webkitpy.tool.commands.rebaseline import * 13 from webkitpy.tool.commands.rebaseline import CopyExistingBaselinesInternal
14 from webkitpy.tool.commands.rebaseline import RebaselineExpectations
15 from webkitpy.tool.commands.rebaseline import Rebaseline
16 from webkitpy.tool.commands.rebaseline import RebaselineJson
17 from webkitpy.tool.commands.rebaseline import RebaselineTest
18 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand
13 from webkitpy.tool.mock_tool import MockWebKitPatch, MockOptions 19 from webkitpy.tool.mock_tool import MockWebKitPatch, MockOptions
14 20
15 21
16 class BaseTestCase(unittest.TestCase): 22 class BaseTestCase(unittest.TestCase):
17 MOCK_WEB_RESULT = 'MOCK Web result, convert 404 to None=True' 23 MOCK_WEB_RESULT = 'MOCK Web result, convert 404 to None=True'
18 WEB_PREFIX = 'https://storage.googleapis.com/chromium-layout-test-archives/M OCK_Mac10_11/results/layout-test-results' 24 WEB_PREFIX = 'https://storage.googleapis.com/chromium-layout-test-archives/M OCK_Mac10_11/results/layout-test-results'
19 25
20 command_constructor = None 26 command_constructor = None
21 27
22 def setUp(self): 28 def setUp(self):
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 self._write(self.mac_expectations_path, """Bug(B) [ Mac Linux Win7 Debug ] fast/dom/Window/window-postmessage-clone-really-deep-array.html [ Pass ] 252 self._write(self.mac_expectations_path, """Bug(B) [ Mac Linux Win7 Debug ] fast/dom/Window/window-postmessage-clone-really-deep-array.html [ Pass ]
247 Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failure ] 253 Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failure ]
248 """) 254 """)
249 self._write("fast/dom/Window/window-postmessage-clone-really-deep-array. html", "Dummy test contents") 255 self._write("fast/dom/Window/window-postmessage-clone-really-deep-array. html", "Dummy test contents")
250 self._write("fast/css/large-list-of-rules-crash.html", "Dummy test conte nts") 256 self._write("fast/css/large-list-of-rules-crash.html", "Dummy test conte nts")
251 self._write("userscripts/another-test.html", "Dummy test contents") 257 self._write("userscripts/another-test.html", "Dummy test contents")
252 258
253 self.options.suffixes = "png,wav,txt" 259 self.options.suffixes = "png,wav,txt"
254 self.command._rebaseline_test_and_update_expectations(self.options) 260 self.command._rebaseline_test_and_update_expectations(self.options)
255 261
256 self.maxDiff = None
257 self.assertItemsEqual(self.tool.web.urls_fetched, 262 self.assertItemsEqual(self.tool.web.urls_fetched,
258 [self.WEB_PREFIX + '/userscripts/another-test-actu al.png', 263 [self.WEB_PREFIX + '/userscripts/another-test-actu al.png',
259 self.WEB_PREFIX + '/userscripts/another-test-actu al.wav', 264 self.WEB_PREFIX + '/userscripts/another-test-actu al.wav',
260 self.WEB_PREFIX + '/userscripts/another-test-actu al.txt']) 265 self.WEB_PREFIX + '/userscripts/another-test-actu al.txt'])
261 new_expectations = self._read(self.mac_expectations_path) 266 new_expectations = self._read(self.mac_expectations_path)
262 self.assertMultiLineEqual(new_expectations, """Bug(B) [ Mac Linux Win7 D ebug ] fast/dom/Window/window-postmessage-clone-really-deep-array.html [ Pass ] 267 self.assertMultiLineEqual(new_expectations, """Bug(B) [ Mac Linux Win7 D ebug ] fast/dom/Window/window-postmessage-clone-really-deep-array.html [ Pass ]
263 Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failure ] 268 Bug(A) [ Debug ] : fast/css/large-list-of-rules-crash.html [ Failure ]
264 """) 269 """)
265 270
266 def test_rebaseline_test(self): 271 def test_rebaseline_test(self):
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 ], 570 ],
566 [ 571 [
567 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', 572 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'txt,png',
568 '--builder', 'MOCK Win7', '--test', 'userscrip ts/first-test.html', '--verbose'], 573 '--builder', 'MOCK Win7', '--test', 'userscrip ts/first-test.html', '--verbose'],
569 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'txt,png', 574 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'txt,png',
570 '--builder', 'MOCK Win7', '--test', 'userscrip ts/second-test.html', '--verbose'] 575 '--builder', 'MOCK Win7', '--test', 'userscrip ts/second-test.html', '--verbose']
571 ] 576 ]
572 ]) 577 ])
573 578
574 579
575 class MockLineRemovingExecutive(MockExecutive):
576
577 def run_in_parallel(self, commands):
578 assert len(commands)
579
580 num_previous_calls = len(self.calls)
581 command_outputs = []
582 for cmd_line, cwd in commands:
583 out = self.run_command(cmd_line, cwd=cwd)
584 if 'rebaseline-test-internal' in cmd_line:
585 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "% s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6])
586 command_outputs.append([0, out, ''])
587
588 new_calls = self.calls[num_previous_calls:]
589 self.calls = self.calls[:num_previous_calls]
590 self.calls.append(new_calls)
591 return command_outputs
592
593 580
594 class TestRebaselineExpectations(BaseTestCase): 581 class TestRebaselineExpectations(BaseTestCase):
595 command_constructor = RebaselineExpectations 582 command_constructor = RebaselineExpectations
596 583
597 def setUp(self): 584 def setUp(self):
598 super(TestRebaselineExpectations, self).setUp() 585 super(TestRebaselineExpectations, self).setUp()
599 self.options = MockOptions(optimize=False, builders=None, suffixes=['txt '], 586 self.options = MockOptions(optimize=False, builders=None, suffixes=['txt '],
600 verbose=False, platform=None, results_directo ry=None) 587 verbose=False, platform=None, results_directo ry=None)
601 588
602 def _write_test_file(self, port, path, contents): 589 def _write_test_file(self, port, path, contents):
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx t', 835 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx t',
849 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text. html'], 836 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text. html'],
850 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx t,png', 837 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx t,png',
851 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text- and-image.html'], 838 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-text- and-image.html'],
852 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn g', 839 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn g',
853 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-image .html'], 840 '--builder', 'MOCK Mac10.10', '--test', 'fast/dom/missing-image .html'],
854 ] 841 ]
855 ]) 842 ])
856 843
857 844
858 class TestAutoRebaseline(BaseTestCase): 845 class MockLineRemovingExecutive(MockExecutive):
859 command_constructor = AutoRebaseline
860 846
861 def _write_test_file(self, port, path, contents): 847 def run_in_parallel(self, commands):
862 abs_path = self.tool.filesystem.join(port.layout_tests_dir(), path) 848 assert len(commands)
863 self.tool.filesystem.write_text_file(abs_path, contents)
864 849
865 def _execute_command_with_mock_options(self, auth_refresh_token_json=None, c ommit_author=None, dry_run=False): 850 num_previous_calls = len(self.calls)
866 self.command.execute( 851 command_outputs = []
867 MockOptions(optimize=True, verbose=False, results_directory=False, 852 for cmd_line, cwd in commands:
868 auth_refresh_token_json=auth_refresh_token_json, 853 out = self.run_command(cmd_line, cwd=cwd)
869 commit_author=commit_author, dry_run=dry_run), 854 if 'rebaseline-test-internal' in cmd_line:
870 [], self.tool) 855 out = '{"add": [], "remove-lines": [{"test": "%s", "builder": "% s"}], "delete": []}\n' % (cmd_line[8], cmd_line[6])
856 command_outputs.append([0, out, ''])
871 857
872 def setUp(self): 858 new_calls = self.calls[num_previous_calls:]
873 super(TestAutoRebaseline, self).setUp() 859 self.calls = self.calls[:num_previous_calls]
874 self.tool.builders = BuilderList({ 860 self.calls.append(new_calls)
875 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": [" Mac10.10", "Release"]}, 861 return command_outputs
876 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": [" Mac10.11", "Release"]},
877 "MOCK Precise": {"port_name": "test-linux-precise", "specifiers": [" Precise", "Release"]},
878 "MOCK Trusty": {"port_name": "test-linux-trusty", "specifiers": ["Tr usty", "Release"]},
879 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", " Release"]},
880 "MOCK Win7 (dbg)": {"port_name": "test-win-win7", "specifiers": ["Wi n7", "Debug"]},
881 })
882
883 self.command.latest_revision_processed_on_all_bots = lambda: 9000
884 self.command.bot_revision_data = lambda scm: [{"builder": "MOCK Win7", " revision": "9000"}]
885
886 def test_release_builders(self):
887 self.tool.builders = BuilderList({
888 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": [" Mac10.10", "Release"]},
889 "MOCK Mac10.11 (dbg)": {"port_name": "test-mac-mac10.11", "specifier s": ["Mac10.11", "Debug"]},
890 "MOCK Mac10.11 ASAN": {"port_name": "test-mac-mac10.11", "specifiers ": ["Mac10.11", "Release"]},
891 })
892 self.assertEqual(self.command._release_builders(), ['MOCK Mac10.10'])
893
894 def test_tests_to_rebaseline(self):
895 def blame(_):
896 return """
897 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline. html [ Failure ]
898 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org@ bbb929c8-8fbe-4397-9dbb-9b2b20218538> 2013-06-14 20:18:46 +0000 11) crbug.com/ 24182 [ Debug ] path/to/norebaseline-email-with-hash.html [ Failure ]
899 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) path/to/rebaseline-without-bug-number. html [ NeedsRebaseline ]
900 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/rebaseline-wi th-modifiers.html [ NeedsRebaseline ]
901 624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 crbug.com/234 path/to/rebaselin e-without-modifiers.html [ NeedsRebaseline ]
902 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org@ bbb929c8-8fbe-4397-9dbb-9b2b20218538> 2013-04-28 04:52:41 +0000 12) crbug.com/ 24182 path/to/rebaseline-new-revision.html [ NeedsRebaseline ]
903 624caaaaaa path/to/TestExpectations (<foo@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/not-cycled-through-bots .html [ NeedsRebaseline ]
904 0000000000 path/to/TestExpectations (<foo@chromium.org@@bbb929 c8-8fbe-4397-9dbb-9b2b20218538> 2013-04-28 04:52:41 +0000 12) crbug.com /24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
905 """
906 self.tool.scm().blame = blame
907
908 min_revision = 9000
909 self.assertEqual(self.command.tests_to_rebaseline(self.tool, min_revisio n, print_revisions=False), (
910 set(['path/to/rebaseline-without-bug-number.html',
911 'path/to/rebaseline-with-modifiers.html', 'path/to/rebaseline-w ithout-modifiers.html']),
912 5678,
913 '624c3081c0',
914 'foobarbaz1@chromium.org',
915 set(['24182', '234']),
916 True))
917
918 def test_tests_to_rebaseline_over_limit(self):
919 def blame(_):
920 result = ""
921 for i in range(0, self.command.MAX_LINES_TO_REBASELINE + 1):
922 result += "624c3081c0 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) crbug.com/24182 path /to/rebaseline-%s.html [ NeedsRebaseline ]\n" % i
923 return result
924 self.tool.scm().blame = blame
925
926 expected_list_of_tests = []
927 for i in range(0, self.command.MAX_LINES_TO_REBASELINE):
928 expected_list_of_tests.append("path/to/rebaseline-%s.html" % i)
929
930 min_revision = 9000
931 self.assertEqual(self.command.tests_to_rebaseline(self.tool, min_revisio n, print_revisions=False), (
932 set(expected_list_of_tests),
933 5678,
934 '624c3081c0',
935 'foobarbaz1@chromium.org',
936 set(['24182']),
937 True))
938
939 def test_commit_message(self):
940 author = "foo@chromium.org"
941 revision = 1234
942 commit = "abcd567"
943 bugs = set()
944 self.assertEqual(self.command.commit_message(author, revision, commit, b ugs),
945 """Auto-rebaseline for r1234
946
947 https://chromium.googlesource.com/chromium/src/+/abcd567
948
949 TBR=foo@chromium.org
950 """)
951
952 bugs = set(["234", "345"])
953 self.assertEqual(self.command.commit_message(author, revision, commit, b ugs),
954 """Auto-rebaseline for r1234
955
956 https://chromium.googlesource.com/chromium/src/+/abcd567
957
958 BUG=234,345
959 TBR=foo@chromium.org
960 """)
961
962 def test_no_needs_rebaseline_lines(self):
963 def blame(_):
964 return """
965 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline. html [ Failure ]
966 """
967 self.tool.scm().blame = blame
968
969 self._execute_command_with_mock_options()
970 self.assertEqual(self.tool.executive.calls, [])
971
972 def test_execute(self):
973 def blame(_):
974 return """
975 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) # Test NeedsRebaseline being in a comment doesn 't bork parsing.
976 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Debug ] path/to/norebaseline. html [ Failure ]
977 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe baseline ]
978 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-06-14 20:18:46 +0000 11) crbug.com/24182 [ Mac10.11 ] fast/dom/prototype -strawberry.html [ NeedsRebaseline ]
979 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 fast/dom/prototype-chocolate.ht ml [ NeedsRebaseline ]
980 624caaaaaa path/to/TestExpectations (<foo@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/not-cycled-through-bots .html [ NeedsRebaseline ]
981 0000000000 path/to/TestExpectations (<foo@chromium.org> 2013-04-28 04:52:41 +0000 12) crbug.com/24182 path/to/locally-changed-lined.h tml [ NeedsRebaseline ]
982 """
983 self.tool.scm().blame = blame
984
985 test_port = self.tool.port_factory.get('test')
986
987 def build_data():
988 # Have prototype-chocolate only fail on "MOCK Mac10.11".
989 self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({
990 "tests": {
991 "fast": {
992 "dom": {
993 "prototype-taco.html": {
994 "expected": "PASS",
995 "actual": "PASS TEXT",
996 "is_unexpected": True
997 },
998 "prototype-chocolate.html": {
999 "expected": "FAIL",
1000 "actual": "PASS"
1001 },
1002 "prototype-strawberry.html": {
1003 "expected": "PASS",
1004 "actual": "IMAGE PASS",
1005 "is_unexpected": True
1006 }
1007 }
1008 }
1009 }
1010 })
1011 return self._build_data
1012
1013 self.command.build_data = build_data
1014
1015 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe ctations_file(), """
1016 crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ]
1017 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
1018 crbug.com/24182 [ Mac10.11 ] fast/dom/prototype-strawberry.html [ NeedsRebaselin e ]
1019 crbug.com/24182 fast/dom/prototype-chocolate.html [ NeedsRebaseline ]
1020 crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ]
1021 crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
1022 """)
1023
1024 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
1025 self._write_test_file(test_port, 'fast/dom/prototype-strawberry.html', " Dummy test contents")
1026 self._write_test_file(test_port, 'fast/dom/prototype-chocolate.html', "D ummy test contents")
1027
1028 self.tool.executive = MockLineRemovingExecutive()
1029
1030 self.tool.builders = BuilderList({
1031 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": [" Mac10.10", "Release"]},
1032 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": [" Mac10.11", "Release"]},
1033 })
1034
1035 self.command.tree_status = lambda: 'closed'
1036 self._execute_command_with_mock_options()
1037 self.assertEqual(self.tool.executive.calls, [])
1038
1039 self.command.tree_status = lambda: 'open'
1040 self.tool.executive.calls = []
1041 self._execute_command_with_mock_options()
1042
1043 self.assertEqual(self.tool.executive.calls, [
1044 [
1045 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix es', 'png',
1046 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-str awberry.html'],
1047 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix es', 'txt',
1048 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac o.html'],
1049 ],
1050 [
1051 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'pn g',
1052 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-str awberry.html'],
1053 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx t',
1054 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac o.html'],
1055 ],
1056 [
1057 ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
1058 '--suffixes', 'png', 'fast/dom/prototype-strawberry.html'],
1059 ['python', 'echo', 'optimize-baselines', '--no-modify-scm',
1060 '--suffixes', 'txt', 'fast/dom/prototype-taco.html'],
1061 ],
1062 ['git', 'cl', 'upload', '-f'],
1063 ['git', 'pull'],
1064 ['git', 'cl', 'land', '-f', '-v'],
1065 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldi ssue'],
1066 ])
1067
1068 # The mac ports should both be removed since they're the only ones in bu ilders._exact_matches.
1069 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g eneric_test_expectations_file()), """
1070 crbug.com/24182 [ Debug ] path/to/norebaseline.html [ Rebaseline ]
1071 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
1072 crbug.com/24182 [ Linux Win ] fast/dom/prototype-chocolate.html [ NeedsRebaselin e ]
1073 crbug.com/24182 path/to/not-cycled-through-bots.html [ NeedsRebaseline ]
1074 crbug.com/24182 path/to/locally-changed-lined.html [ NeedsRebaseline ]
1075 """)
1076
1077 def test_execute_git_cl_hangs(self):
1078 def blame(_):
1079 return """
1080 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe baseline ]
1081 """
1082 self.tool.scm().blame = blame
1083
1084 test_port = self.tool.port_factory.get('test')
1085
1086 original_build_data = self.command.build_data
1087
1088 def build_data():
1089 original_build_data()
1090 # Have prototype-chocolate only fail on "MOCK Mac10.11".
1091 self._build_data[Build('MOCK Mac10.11')] = LayoutTestResults({
1092 "tests": {
1093 "fast": {
1094 "dom": {
1095 "prototype-taco.html": {
1096 "expected": "PASS",
1097 "actual": "PASS TEXT",
1098 "is_unexpected": True
1099 }
1100 }
1101 }
1102 }
1103 })
1104 return self._build_data
1105
1106 self.command.build_data = build_data
1107
1108 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe ctations_file(), """
1109 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
1110 """)
1111
1112 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
1113
1114 self.tool.builders = BuilderList({
1115 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": [" Mac10.11", "Release"]},
1116 })
1117
1118 self.command.SECONDS_BEFORE_GIVING_UP = 0
1119 self.command.tree_status = lambda: 'open'
1120 self.tool.executive = MockExecutive()
1121 self.tool.executive.calls = []
1122 self._execute_command_with_mock_options()
1123
1124 self.assertEqual(self.tool.executive.calls, [
1125 [
1126 ['python', 'echo', 'copy-existing-baselines-internal', '--suffix es', 'txt',
1127 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac o.html'],
1128 ],
1129 [
1130 ['python', 'echo', 'rebaseline-test-internal', '--suffixes', 'tx t',
1131 '--builder', 'MOCK Mac10.11', '--test', 'fast/dom/prototype-tac o.html'],
1132 ],
1133 [['python', 'echo', 'optimize-baselines', '--no-modify-scm', '--suff ixes', 'txt', 'fast/dom/prototype-taco.html']],
1134 ['git', 'cl', 'upload', '-f'],
1135 ])
1136
1137 def test_execute_test_passes_everywhere(self):
1138 def blame(_):
1139 return """
1140 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe baseline ]
1141 """
1142 self.tool.scm().blame = blame
1143
1144 test_port = self.tool.port_factory.get('test')
1145
1146 def build_data():
1147 self._build_data[Build('MOCK Mac10.10')] = self._build_data[Build('M OCK Mac10.11')] = LayoutTestResults({
1148 "tests": {
1149 "fast": {
1150 "dom": {
1151 "prototype-taco.html": {
1152 "expected": "FAIL",
1153 "actual": "PASS",
1154 "is_unexpected": True
1155 }
1156 }
1157 }
1158 }
1159 })
1160 return self._build_data
1161
1162 self.command.build_data = build_data
1163
1164 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe ctations_file(), """
1165 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
1166 """)
1167
1168 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
1169
1170 self.tool.executive = MockLineRemovingExecutive()
1171
1172 self.tool.builders = BuilderList({
1173 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": [" Mac10.10", "Release"]},
1174 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": [" Mac10.11", "Release"]},
1175 })
1176
1177 self.command.tree_status = lambda: 'open'
1178 self._execute_command_with_mock_options()
1179 self.assertEqual(self.tool.executive.calls, [
1180 ['git', 'cl', 'upload', '-f'],
1181 ['git', 'pull'],
1182 ['git', 'cl', 'land', '-f', '-v'],
1183 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietveldi ssue'],
1184 ])
1185
1186 # The mac ports should both be removed since they're the only ones in bu ilders._exact_matches.
1187 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g eneric_test_expectations_file()), """
1188 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
1189 """)
1190
1191 def test_execute_use_alternate_rebaseline_branch(self):
1192 def blame(_):
1193 return """
1194 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe baseline ]
1195 """
1196 self.tool.scm().blame = blame
1197
1198 test_port = self.tool.port_factory.get('test')
1199
1200 def build_data():
1201 self._build_data[Build('MOCK Win')] = LayoutTestResults({
1202 "tests": {
1203 "fast": {
1204 "dom": {
1205 "prototype-taco.html": {
1206 "expected": "FAIL",
1207 "actual": "PASS",
1208 "is_unexpected": True
1209 }
1210 }
1211 }
1212 }
1213 })
1214 return self._build_data
1215
1216 self.command.build_data = build_data
1217
1218 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe ctations_file(), """
1219 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
1220 """)
1221
1222 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
1223
1224 self.tool.executive = MockLineRemovingExecutive()
1225
1226 self.tool.builders = BuilderList({
1227 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", " Release"]},
1228 })
1229 old_branch_name = self.tool.scm().current_branch_or_ref
1230 try:
1231 self.command.tree_status = lambda: 'open'
1232 self.tool.scm().current_branch_or_ref = lambda: 'auto-rebaseline-tem porary-branch'
1233 self._execute_command_with_mock_options()
1234 self.assertEqual(self.tool.executive.calls, [
1235 ['git', 'cl', 'upload', '-f'],
1236 ['git', 'pull'],
1237 ['git', 'cl', 'land', '-f', '-v'],
1238 ['git', 'config', 'branch.auto-rebaseline-alt-temporary-branch.r ietveldissue'],
1239 ])
1240
1241 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_ to_generic_test_expectations_file()), """
1242 Bug(foo) [ Linux Mac Win10 ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
1243 """)
1244 finally:
1245 self.tool.scm().current_branch_or_ref = old_branch_name
1246
1247 def test_execute_stuck_on_alternate_rebaseline_branch(self):
1248 def blame(_):
1249 return """
1250 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe baseline ]
1251 """
1252 self.tool.scm().blame = blame
1253
1254 test_port = self.tool.port_factory.get('test')
1255
1256 def build_data():
1257 self._build_data[Build('MOCK Win')] = LayoutTestResults({
1258 "tests": {
1259 "fast": {
1260 "dom": {
1261 "prototype-taco.html": {
1262 "expected": "FAIL",
1263 "actual": "PASS",
1264 "is_unexpected": True
1265 }
1266 }
1267 }
1268 }
1269 })
1270 return self._build_data
1271
1272 self.command.build_data = build_data
1273
1274 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe ctations_file(), """
1275 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
1276 """)
1277
1278 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
1279
1280 self.tool.executive = MockLineRemovingExecutive()
1281
1282 self.tool.builders = BuilderList({
1283 "MOCK Win7": {"port_name": "test-win-win7", "specifiers": ["Win7", " Release"]},
1284 })
1285
1286 old_branch_name = self.tool.scm().current_branch_or_ref
1287 try:
1288 self.command.tree_status = lambda: 'open'
1289 self.tool.scm().current_branch_or_ref = lambda: 'auto-rebaseline-alt -temporary-branch'
1290 self._execute_command_with_mock_options()
1291 self.assertEqual(self.tool.executive.calls, [
1292 ['git', 'cl', 'upload', '-f'],
1293 ['git', 'pull'],
1294 ['git', 'cl', 'land', '-f', '-v'],
1295 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv eldissue'],
1296 ])
1297
1298 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_ to_generic_test_expectations_file()), """
1299 Bug(foo) [ Linux Mac Win10 ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
1300 """)
1301 finally:
1302 self.tool.scm().current_branch_or_ref = old_branch_name
1303
1304 def _basic_execute_test(self, expected_executive_calls, auth_refresh_token_j son=None, commit_author=None, dry_run=False):
1305 def blame(_):
1306 return """
1307 6469e754a1 path/to/TestExpectations (<foobarbaz1@chromium.org> 2013-04-28 04:52:41 +0000 13) Bug(foo) fast/dom/prototype-taco.html [ NeedsRe baseline ]
1308 """
1309 self.tool.scm().blame = blame
1310
1311 test_port = self.tool.port_factory.get('test')
1312
1313 def build_data():
1314 self._build_data[Build('MOCK Mac10.10')] = self._build_data[Build('M OCK Mac10.11')] = LayoutTestResults({
1315 "tests": {
1316 "fast": {
1317 "dom": {
1318 "prototype-taco.html": {
1319 "expected": "FAIL",
1320 "actual": "PASS",
1321 "is_unexpected": True
1322 }
1323 }
1324 }
1325 }
1326 })
1327 return self._build_data
1328
1329 self.command.build_data = build_data
1330
1331 self.tool.filesystem.write_text_file(test_port.path_to_generic_test_expe ctations_file(), """
1332 Bug(foo) fast/dom/prototype-taco.html [ NeedsRebaseline ]
1333 """)
1334
1335 self._write_test_file(test_port, 'fast/dom/prototype-taco.html', "Dummy test contents")
1336
1337 self.tool.executive = MockLineRemovingExecutive()
1338
1339 self.tool.builders = BuilderList({
1340 "MOCK Mac10.10": {"port_name": "test-mac-mac10.10", "specifiers": [" Mac10.10", "Release"]},
1341 "MOCK Mac10.11": {"port_name": "test-mac-mac10.11", "specifiers": [" Mac10.11", "Release"]},
1342 })
1343
1344 self.command.tree_status = lambda: 'open'
1345 self._execute_command_with_mock_options(auth_refresh_token_json=auth_ref resh_token_json,
1346 commit_author=commit_author, dry _run=dry_run)
1347 self.assertEqual(self.tool.executive.calls, expected_executive_calls)
1348
1349 # The mac ports should both be removed since they're the only ones in bu ilders._exact_matches.
1350 self.assertEqual(self.tool.filesystem.read_text_file(test_port.path_to_g eneric_test_expectations_file()), """
1351 Bug(foo) [ Linux Win ] fast/dom/prototype-taco.html [ NeedsRebaseline ]
1352 """)
1353
1354 def test_execute_with_rietveld_auth_refresh_token(self):
1355 RIETVELD_REFRESH_TOKEN = '/creds/refresh_tokens/test_rietveld_token'
1356 self._basic_execute_test(
1357 [
1358 ['git', 'cl', 'upload', '-f', '--auth-refresh-token-json', RIETV ELD_REFRESH_TOKEN],
1359 ['git', 'pull'],
1360 ['git', 'cl', 'land', '-f', '-v', '--auth-refresh-token-json', R IETVELD_REFRESH_TOKEN],
1361 ['git', 'config', 'branch.auto-rebaseline-temporary-branch.rietv eldissue'],
1362 ],
1363 auth_refresh_token_json=RIETVELD_REFRESH_TOKEN)
1364
1365 def test_execute_with_dry_run(self):
1366 self._basic_execute_test([], dry_run=True)
1367 self.assertEqual(self.tool.scm().local_commits(), [])
1368
1369 def test_bot_revision_data(self):
1370 self._setup_mock_build_data()
1371 self.assertEqual(
1372 self.command.bot_revision_data(self.tool.scm()),
1373 [{'builder': 'MOCK Win7', 'revision': '9000'}])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698