| OLD | NEW | 
|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python | 
| 2 # Copyright 2013 the V8 project authors. All rights reserved. | 2 # Copyright 2013 the V8 project authors. All rights reserved. | 
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without | 
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are | 
| 5 # met: | 5 # met: | 
| 6 # | 6 # | 
| 7 #     * Redistributions of source code must retain the above copyright | 7 #     * Redistributions of source code must retain the above copyright | 
| 8 #       notice, this list of conditions and the following disclaimer. | 8 #       notice, this list of conditions and the following disclaimer. | 
| 9 #     * Redistributions in binary form must reproduce the above | 9 #     * Redistributions in binary form must reproduce the above | 
| 10 #       copyright notice, this list of conditions and the following | 10 #       copyright notice, this list of conditions and the following | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 38 import common_includes | 38 import common_includes | 
| 39 from common_includes import * | 39 from common_includes import * | 
| 40 import merge_to_branch | 40 import merge_to_branch | 
| 41 from merge_to_branch import * | 41 from merge_to_branch import * | 
| 42 import push_to_trunk | 42 import push_to_trunk | 
| 43 from push_to_trunk import * | 43 from push_to_trunk import * | 
| 44 import chromium_roll | 44 import chromium_roll | 
| 45 from chromium_roll import CHROMIUM | 45 from chromium_roll import CHROMIUM | 
| 46 from chromium_roll import DEPS_FILE | 46 from chromium_roll import DEPS_FILE | 
| 47 from chromium_roll import ChromiumRoll | 47 from chromium_roll import ChromiumRoll | 
|  | 48 import releases | 
|  | 49 from releases import Releases | 
| 48 | 50 | 
| 49 | 51 | 
| 50 TEST_CONFIG = { | 52 TEST_CONFIG = { | 
| 51   BRANCHNAME: "test-prepare-push", | 53   BRANCHNAME: "test-prepare-push", | 
| 52   TRUNKBRANCH: "test-trunk-push", | 54   TRUNKBRANCH: "test-trunk-push", | 
| 53   PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 55   PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 
| 54   TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 56   TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 
| 55   DOT_GIT_LOCATION: None, | 57   DOT_GIT_LOCATION: None, | 
| 56   VERSION_FILE: None, | 58   VERSION_FILE: None, | 
| 57   CHANGELOG_FILE: None, | 59   CHANGELOG_FILE: None, | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 68 } | 70 } | 
| 69 | 71 | 
| 70 | 72 | 
| 71 AUTO_PUSH_ARGS = [ | 73 AUTO_PUSH_ARGS = [ | 
| 72   "-a", "author@chromium.org", | 74   "-a", "author@chromium.org", | 
| 73   "-r", "reviewer@chromium.org", | 75   "-r", "reviewer@chromium.org", | 
| 74 ] | 76 ] | 
| 75 | 77 | 
| 76 | 78 | 
| 77 class ToplevelTest(unittest.TestCase): | 79 class ToplevelTest(unittest.TestCase): | 
|  | 80   def testSortBranches(self): | 
|  | 81     S = releases.SortBranches | 
|  | 82     self.assertEquals(["3.1", "2.25"], S(["2.25", "3.1"])[0:2]) | 
|  | 83     self.assertEquals(["3.0", "2.25"], S(["2.25", "3.0", "2.24"])[0:2]) | 
|  | 84     self.assertEquals(["3.11", "3.2"], S(["3.11", "3.2", "2.24"])[0:2]) | 
|  | 85 | 
|  | 86   def testFilterDuplicatesAndReverse(self): | 
|  | 87     F = releases.FilterDuplicatesAndReverse | 
|  | 88     self.assertEquals([], F([])) | 
|  | 89     self.assertEquals([["100", "10"]], F([["100", "10"]])) | 
|  | 90     self.assertEquals([["99", "9"], ["100", "10"]], | 
|  | 91                       F([["100", "10"], ["99", "9"]])) | 
|  | 92     self.assertEquals([["98", "9"], ["100", "10"]], | 
|  | 93                       F([["100", "10"], ["99", "9"], ["98", "9"]])) | 
|  | 94     self.assertEquals([["98", "9"], ["99", "10"]], | 
|  | 95                       F([["100", "10"], ["99", "10"], ["98", "9"]])) | 
|  | 96 | 
|  | 97   def testBuildRevisionRanges(self): | 
|  | 98     B = releases.BuildRevisionRanges | 
|  | 99     self.assertEquals({}, B([])) | 
|  | 100     self.assertEquals({"10": "100"}, B([["100", "10"]])) | 
|  | 101     self.assertEquals({"10": "100", "9": "99:99"}, | 
|  | 102                       B([["100", "10"], ["99", "9"]])) | 
|  | 103     self.assertEquals({"10": "100", "9": "97:99"}, | 
|  | 104                       B([["100", "10"], ["98", "9"], ["97", "9"]])) | 
|  | 105     self.assertEquals({"10": "100", "9": "99:99", "3": "91:98"}, | 
|  | 106                       B([["100", "10"], ["99", "9"], ["91", "3"]])) | 
|  | 107     self.assertEquals({"13": "101", "12": "100:100", "9": "94:97", | 
|  | 108                        "3": "91:93,98:99"}, | 
|  | 109                       B([["101", "13"], ["100", "12"], ["98", "3"], | 
|  | 110                          ["94", "9"], ["91", "3"]])) | 
|  | 111 | 
| 78   def testMakeComment(self): | 112   def testMakeComment(self): | 
| 79     self.assertEquals("#   Line 1\n#   Line 2\n#", | 113     self.assertEquals("#   Line 1\n#   Line 2\n#", | 
| 80                       MakeComment("    Line 1\n    Line 2\n")) | 114                       MakeComment("    Line 1\n    Line 2\n")) | 
| 81     self.assertEquals("#Line 1\n#Line 2", | 115     self.assertEquals("#Line 1\n#Line 2", | 
| 82                       MakeComment("Line 1\n Line 2")) | 116                       MakeComment("Line 1\n Line 2")) | 
| 83 | 117 | 
| 84   def testStripComments(self): | 118   def testStripComments(self): | 
| 85     self.assertEquals("    Line 1\n    Line 3\n", | 119     self.assertEquals("    Line 1\n    Line 3\n", | 
| 86         StripComments("    Line 1\n#   Line 2\n    Line 3\n#\n")) | 120         StripComments("    Line 1\n#   Line 2\n    Line 3\n#\n")) | 
| 87     self.assertEquals("\nLine 2 ### Test\n #", | 121     self.assertEquals("\nLine 2 ### Test\n #", | 
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 290                              % (self._name, self._index, len(self._recipe))) | 324                              % (self._name, self._index, len(self._recipe))) | 
| 291 | 325 | 
| 292 | 326 | 
| 293 class ScriptTest(unittest.TestCase): | 327 class ScriptTest(unittest.TestCase): | 
| 294   def MakeEmptyTempFile(self): | 328   def MakeEmptyTempFile(self): | 
| 295     handle, name = tempfile.mkstemp() | 329     handle, name = tempfile.mkstemp() | 
| 296     os.close(handle) | 330     os.close(handle) | 
| 297     self._tmp_files.append(name) | 331     self._tmp_files.append(name) | 
| 298     return name | 332     return name | 
| 299 | 333 | 
| 300   def WriteFakeVersionFile(self, build=4): | 334   def WriteFakeVersionFile(self, minor=22, build=4, patch=0): | 
| 301     with open(TEST_CONFIG[VERSION_FILE], "w") as f: | 335     with open(TEST_CONFIG[VERSION_FILE], "w") as f: | 
| 302       f.write("  // Some line...\n") | 336       f.write("  // Some line...\n") | 
| 303       f.write("\n") | 337       f.write("\n") | 
| 304       f.write("#define MAJOR_VERSION    3\n") | 338       f.write("#define MAJOR_VERSION    3\n") | 
| 305       f.write("#define MINOR_VERSION    22\n") | 339       f.write("#define MINOR_VERSION    %s\n" % minor) | 
| 306       f.write("#define BUILD_NUMBER     %s\n" % build) | 340       f.write("#define BUILD_NUMBER     %s\n" % build) | 
| 307       f.write("#define PATCH_LEVEL      0\n") | 341       f.write("#define PATCH_LEVEL      %s\n" % patch) | 
| 308       f.write("  // Some line...\n") | 342       f.write("  // Some line...\n") | 
| 309       f.write("#define IS_CANDIDATE_VERSION 0\n") | 343       f.write("#define IS_CANDIDATE_VERSION 0\n") | 
| 310 | 344 | 
| 311   def MakeStep(self): | 345   def MakeStep(self): | 
| 312     """Convenience wrapper.""" | 346     """Convenience wrapper.""" | 
| 313     options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) | 347     options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) | 
| 314     return MakeStep(step_class=Step, state=self._state, | 348     return MakeStep(step_class=Step, state=self._state, | 
| 315                     config=TEST_CONFIG, side_effect_handler=self, | 349                     config=TEST_CONFIG, side_effect_handler=self, | 
| 316                     options=options) | 350                     options=options) | 
| 317 | 351 | 
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1109             "34567"] | 1143             "34567"] | 
| 1110 | 1144 | 
| 1111     # The first run of the script stops because of the svn being down. | 1145     # The first run of the script stops because of the svn being down. | 
| 1112     self.assertRaises(GitFailedException, | 1146     self.assertRaises(GitFailedException, | 
| 1113         lambda: MergeToBranch(TEST_CONFIG, self).Run(args)) | 1147         lambda: MergeToBranch(TEST_CONFIG, self).Run(args)) | 
| 1114 | 1148 | 
| 1115     # Test that state recovery after restarting the script works. | 1149     # Test that state recovery after restarting the script works. | 
| 1116     args += ["-s", "3"] | 1150     args += ["-s", "3"] | 
| 1117     MergeToBranch(TEST_CONFIG, self).Run(args) | 1151     MergeToBranch(TEST_CONFIG, self).Run(args) | 
| 1118 | 1152 | 
|  | 1153   def testReleases(self): | 
|  | 1154     json_output = self.MakeEmptyTempFile() | 
|  | 1155     csv_output = self.MakeEmptyTempFile() | 
|  | 1156     TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 
|  | 1157     self.WriteFakeVersionFile() | 
|  | 1158 | 
|  | 1159     TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 
|  | 1160     if not os.path.exists(TEST_CONFIG[CHROMIUM]): | 
|  | 1161       os.makedirs(TEST_CONFIG[CHROMIUM]) | 
|  | 1162     def WriteDEPS(revision): | 
|  | 1163       TextToFile("Line\n   \"v8_revision\": \"%s\",\n  line\n" % revision, | 
|  | 1164                  TEST_CONFIG[DEPS_FILE]) | 
|  | 1165     WriteDEPS(567) | 
|  | 1166 | 
|  | 1167     def ResetVersion(minor, build, patch=0): | 
|  | 1168       return lambda: self.WriteFakeVersionFile(minor=minor, | 
|  | 1169                                                build=build, | 
|  | 1170                                                patch=patch) | 
|  | 1171 | 
|  | 1172     def ResetDEPS(revision): | 
|  | 1173       return lambda: WriteDEPS(revision) | 
|  | 1174 | 
|  | 1175     self.ExpectGit([ | 
|  | 1176       Git("status -s -uno", ""), | 
|  | 1177       Git("status -s -b -uno", "## some_branch\n"), | 
|  | 1178       Git("svn fetch", ""), | 
|  | 1179       Git("branch", "  branch1\n* branch2\n"), | 
|  | 1180       Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""), | 
|  | 1181       Git("branch", "  branch1\n* branch2\n"), | 
|  | 1182       Git("checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""), | 
|  | 1183       Git("branch -r", "  svn/3.21\n  svn/3.3\n"), | 
|  | 1184       Git("reset --hard svn/3.3", ""), | 
|  | 1185       Git("log --format=%H", "hash1\nhash2"), | 
|  | 1186       Git("diff --name-only hash1 hash1^", ""), | 
|  | 1187       Git("diff --name-only hash2 hash2^", TEST_CONFIG[VERSION_FILE]), | 
|  | 1188       Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 
|  | 1189           cb=ResetVersion(3, 1, 1)), | 
|  | 1190       Git("log -1 --format=%B hash2", "Version 3.3.1.1 (merged 12)"), | 
|  | 1191       Git("log -1 --format=%s hash2", ""), | 
|  | 1192       Git("svn find-rev hash2", "234"), | 
|  | 1193       Git("checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", | 
|  | 1194           cb=ResetVersion(22, 5)), | 
|  | 1195       Git("reset --hard svn/3.21", ""), | 
|  | 1196       Git("log --format=%H", "hash3\nhash4\nhash5\n"), | 
|  | 1197       Git("diff --name-only hash3 hash3^", TEST_CONFIG[VERSION_FILE]), | 
|  | 1198       Git("checkout -f hash3 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 
|  | 1199           cb=ResetVersion(21, 2)), | 
|  | 1200       Git("log -1 --format=%s hash3", ""), | 
|  | 1201       Git("svn find-rev hash3", "123"), | 
|  | 1202       Git("checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", | 
|  | 1203           cb=ResetVersion(22, 5)), | 
|  | 1204       Git("reset --hard svn/trunk", ""), | 
|  | 1205       Git("log --format=%H", "hash6\n"), | 
|  | 1206       Git("diff --name-only hash6 hash6^", TEST_CONFIG[VERSION_FILE]), | 
|  | 1207       Git("checkout -f hash6 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 
|  | 1208           cb=ResetVersion(22, 3)), | 
|  | 1209       Git("log -1 --format=%s hash6", ""), | 
|  | 1210       Git("svn find-rev hash6", "345"), | 
|  | 1211       Git("checkout -f HEAD -- %s" % TEST_CONFIG[VERSION_FILE], "", | 
|  | 1212           cb=ResetVersion(22, 5)), | 
|  | 1213       Git("status -s -uno", ""), | 
|  | 1214       Git("checkout -f master", ""), | 
|  | 1215       Git("pull", ""), | 
|  | 1216       Git("checkout -b %s" % TEST_CONFIG[BRANCHNAME], ""), | 
|  | 1217       Git("log --format=%H --grep=\"V8\"", "c_hash1\nc_hash2\n"), | 
|  | 1218       Git("diff --name-only c_hash1 c_hash1^", ""), | 
|  | 1219       Git("diff --name-only c_hash2 c_hash2^", TEST_CONFIG[DEPS_FILE]), | 
|  | 1220       Git("checkout -f c_hash2 -- %s" % TEST_CONFIG[DEPS_FILE], "", | 
|  | 1221           cb=ResetDEPS(345)), | 
|  | 1222       Git("svn find-rev c_hash2", "4567"), | 
|  | 1223       Git("checkout -f HEAD -- %s" % TEST_CONFIG[DEPS_FILE], "", | 
|  | 1224           cb=ResetDEPS(567)), | 
|  | 1225       Git("checkout -f master", ""), | 
|  | 1226       Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 
|  | 1227       Git("checkout -f some_branch", ""), | 
|  | 1228       Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""), | 
|  | 1229       Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 
|  | 1230     ]) | 
|  | 1231 | 
|  | 1232     args = ["-c", TEST_CONFIG[CHROMIUM], | 
|  | 1233             "--json", json_output, | 
|  | 1234             "--csv", csv_output, | 
|  | 1235             "--max-releases", "1"] | 
|  | 1236     Releases(TEST_CONFIG, self).Run(args) | 
|  | 1237 | 
|  | 1238     # Check expected output. | 
|  | 1239     csv = ("3.22.3,trunk,345,4567,\r\n" | 
|  | 1240            "3.21.2,3.21,123,,\r\n" | 
|  | 1241            "3.3.1.1,3.3,234,,12\r\n") | 
|  | 1242     self.assertEquals(csv, FileToText(csv_output)) | 
|  | 1243 | 
|  | 1244     expected_json = [ | 
|  | 1245       {"bleeding_edge": "", "patches_merged": "", "version": "3.22.3", | 
|  | 1246        "chromium_revision": "4567", "branch": "trunk", "revision": "345"}, | 
|  | 1247       {"patches_merged": "", "bleeding_edge": "", "version": "3.21.2", | 
|  | 1248        "branch": "3.21", "revision": "123"}, | 
|  | 1249       {"patches_merged": "12", "bleeding_edge": "", "version": "3.3.1.1", | 
|  | 1250        "branch": "3.3", "revision": "234"} | 
|  | 1251     ] | 
|  | 1252     self.assertEquals(expected_json, json.loads(FileToText(json_output))) | 
|  | 1253 | 
| 1119 | 1254 | 
| 1120 class SystemTest(unittest.TestCase): | 1255 class SystemTest(unittest.TestCase): | 
| 1121   def testReload(self): | 1256   def testReload(self): | 
| 1122     step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 1257     step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 
| 1123                     side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 1258                     side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 
| 1124     body = step.Reload( | 1259     body = step.Reload( | 
| 1125 """------------------------------------------------------------------------ | 1260 """------------------------------------------------------------------------ | 
| 1126 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 1261 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 
| 1127 | 1262 | 
| 1128 Prepare push to trunk.  Now working on version 3.23.11. | 1263 Prepare push to trunk.  Now working on version 3.23.11. | 
| 1129 | 1264 | 
| 1130 R=danno@chromium.org | 1265 R=danno@chromium.org | 
| 1131 | 1266 | 
| 1132 Review URL: https://codereview.chromium.org/83173002 | 1267 Review URL: https://codereview.chromium.org/83173002 | 
| 1133 | 1268 | 
| 1134 ------------------------------------------------------------------------""") | 1269 ------------------------------------------------------------------------""") | 
| 1135     self.assertEquals( | 1270     self.assertEquals( | 
| 1136 """Prepare push to trunk.  Now working on version 3.23.11. | 1271 """Prepare push to trunk.  Now working on version 3.23.11. | 
| 1137 | 1272 | 
| 1138 R=danno@chromium.org | 1273 R=danno@chromium.org | 
| 1139 | 1274 | 
| 1140 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1275 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 
| OLD | NEW | 
|---|