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 30 matching lines...) Expand all Loading... |
41 import merge_to_branch | 41 import merge_to_branch |
42 from merge_to_branch import * | 42 from merge_to_branch import * |
43 import push_to_trunk | 43 import push_to_trunk |
44 from push_to_trunk import * | 44 from push_to_trunk import * |
45 import chromium_roll | 45 import chromium_roll |
46 from chromium_roll import CHROMIUM | 46 from chromium_roll import CHROMIUM |
47 from chromium_roll import DEPS_FILE | 47 from chromium_roll import DEPS_FILE |
48 from chromium_roll import ChromiumRoll | 48 from chromium_roll import ChromiumRoll |
49 import releases | 49 import releases |
50 from releases import Releases | 50 from releases import Releases |
| 51 import bump_up_version |
| 52 from bump_up_version import BumpUpVersion |
| 53 from bump_up_version import LastChangeBailout |
| 54 from bump_up_version import LKGRVersionUpToDateBailout |
51 | 55 |
52 | 56 |
53 TEST_CONFIG = { | 57 TEST_CONFIG = { |
54 BRANCHNAME: "test-prepare-push", | 58 BRANCHNAME: "test-prepare-push", |
55 TRUNKBRANCH: "test-trunk-push", | 59 TRUNKBRANCH: "test-trunk-push", |
56 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 60 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
57 DOT_GIT_LOCATION: None, | 61 DOT_GIT_LOCATION: None, |
58 VERSION_FILE: None, | 62 VERSION_FILE: None, |
59 CHANGELOG_FILE: None, | 63 CHANGELOG_FILE: None, |
60 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 64 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 349 |
346 def MakeStep(self): | 350 def MakeStep(self): |
347 """Convenience wrapper.""" | 351 """Convenience wrapper.""" |
348 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) | 352 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) |
349 return MakeStep(step_class=Step, state=self._state, | 353 return MakeStep(step_class=Step, state=self._state, |
350 config=TEST_CONFIG, side_effect_handler=self, | 354 config=TEST_CONFIG, side_effect_handler=self, |
351 options=options) | 355 options=options) |
352 | 356 |
353 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): | 357 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): |
354 """Convenience wrapper.""" | 358 """Convenience wrapper.""" |
355 args = args or ["-m"] | 359 args = args if args is not None else ["-m"] |
356 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) | 360 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) |
357 | 361 |
358 def GitMock(self, cmd, args="", pipe=True): | 362 def GitMock(self, cmd, args="", pipe=True): |
359 print "%s %s" % (cmd, args) | 363 print "%s %s" % (cmd, args) |
360 return self._git_mock.Call("git", args) | 364 return self._git_mock.Call("git", args) |
361 | 365 |
362 def LogMock(self, cmd, args=""): | 366 def LogMock(self, cmd, args=""): |
363 print "Log: %s %s" % (cmd, args) | 367 print "Log: %s %s" % (cmd, args) |
364 | 368 |
365 MOCKS = { | 369 MOCKS = { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 594 |
591 self.ExpectReadline([ | 595 self.ExpectReadline([ |
592 RL(""), # Open editor. | 596 RL(""), # Open editor. |
593 ]) | 597 ]) |
594 | 598 |
595 self.RunStep(PushToTrunk, EditChangeLog) | 599 self.RunStep(PushToTrunk, EditChangeLog) |
596 | 600 |
597 self.assertEquals("New\n Lines", | 601 self.assertEquals("New\n Lines", |
598 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) | 602 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) |
599 | 603 |
| 604 # Version on trunk: 3.22.4.0. Version on master (bleeding_edge): 3.22.6. |
| 605 # Make sure that the increment is 3.22.7.0. |
600 def testIncrementVersion(self): | 606 def testIncrementVersion(self): |
601 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 607 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
602 self.WriteFakeVersionFile() | 608 self.WriteFakeVersionFile() |
603 self._state["last_push_trunk"] = "hash1" | 609 self._state["last_push_trunk"] = "hash1" |
| 610 self._state["latest_build"] = "6" |
| 611 self._state["latest_version"] = "3.22.6.0" |
604 | 612 |
605 self.ExpectGit([ | 613 self.ExpectGit([ |
606 Git("checkout -f hash1 -- %s" % TEST_CONFIG[VERSION_FILE], "") | 614 Git("checkout -f hash1 -- %s" % TEST_CONFIG[VERSION_FILE], ""), |
| 615 Git("checkout -f master -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 616 cb=lambda: self.WriteFakeVersionFile(22, 6)), |
607 ]) | 617 ]) |
608 | 618 |
609 self.ExpectReadline([ | 619 self.ExpectReadline([ |
610 RL("Y"), # Increment build number. | 620 RL("Y"), # Increment build number. |
611 ]) | 621 ]) |
612 | 622 |
613 self.RunStep(PushToTrunk, IncrementVersion) | 623 self.RunStep(PushToTrunk, IncrementVersion) |
614 | 624 |
615 self.assertEquals("3", self._state["new_major"]) | 625 self.assertEquals("3", self._state["new_major"]) |
616 self.assertEquals("22", self._state["new_minor"]) | 626 self.assertEquals("22", self._state["new_minor"]) |
617 self.assertEquals("5", self._state["new_build"]) | 627 self.assertEquals("7", self._state["new_build"]) |
618 self.assertEquals("0", self._state["new_patch"]) | 628 self.assertEquals("0", self._state["new_patch"]) |
619 | 629 |
620 def _TestSquashCommits(self, change_log, expected_msg): | 630 def _TestSquashCommits(self, change_log, expected_msg): |
621 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 631 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
622 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: | 632 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
623 f.write(change_log) | 633 f.write(change_log) |
624 | 634 |
625 self.ExpectGit([ | 635 self.ExpectGit([ |
626 Git("diff svn/trunk hash1", "patch content"), | 636 Git("diff svn/trunk hash1", "patch content"), |
627 Git("svn find-rev hash1", "123455\n"), | 637 Git("svn find-rev hash1", "123455\n"), |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 Git("branch", " branch1\n* branch2\n"), | 744 Git("branch", " branch1\n* branch2\n"), |
735 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), | 745 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), |
736 Git("svn find-rev r123455", "push_hash\n"), | 746 Git("svn find-rev r123455", "push_hash\n"), |
737 Git(("log -1 --format=%H --grep=" | 747 Git(("log -1 --format=%H --grep=" |
738 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " | 748 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " |
739 "svn/trunk"), "hash2\n"), | 749 "svn/trunk"), "hash2\n"), |
740 Git("log -1 hash2", "Log message\n"), | 750 Git("log -1 hash2", "Log message\n"), |
741 Git("log -1 --format=%s hash2", | 751 Git("log -1 --format=%s hash2", |
742 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), | 752 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), |
743 Git("svn find-rev r1234", "hash3\n"), | 753 Git("svn find-rev r1234", "hash3\n"), |
| 754 Git("checkout -f master -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 755 cb=self.WriteFakeVersionFile), |
744 Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", | 756 Git("checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", |
745 cb=self.WriteFakeVersionFile), | 757 cb=self.WriteFakeVersionFile), |
746 Git("log --format=%H hash3..push_hash", "rev1\n"), | 758 Git("log --format=%H hash3..push_hash", "rev1\n"), |
747 Git("log -1 --format=%s rev1", "Log text 1.\n"), | 759 Git("log -1 --format=%s rev1", "Log text 1.\n"), |
748 Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), | 760 Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), |
749 Git("log -1 --format=%an rev1", "author1@chromium.org\n"), | 761 Git("log -1 --format=%an rev1", "author1@chromium.org\n"), |
750 Git("svn fetch", "fetch result\n"), | 762 Git("svn fetch", "fetch result\n"), |
751 Git("checkout -f svn/bleeding_edge", ""), | 763 Git("checkout -f svn/bleeding_edge", ""), |
752 Git("diff svn/trunk push_hash", "patch content\n"), | 764 Git("diff svn/trunk push_hash", "patch content\n"), |
753 Git("svn find-rev push_hash", "123455\n"), | 765 Git("svn find-rev push_hash", "123455\n"), |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 "review_link": "", "date": "03:15", "chromium_branch": "", | 1271 "review_link": "", "date": "03:15", "chromium_branch": "", |
1260 "revision_link": "https://code.google.com/p/v8/source/detail?r=123"}, | 1272 "revision_link": "https://code.google.com/p/v8/source/detail?r=123"}, |
1261 {"patches_merged": "12", "bleeding_edge": "", "version": "3.3.1.1", | 1273 {"patches_merged": "12", "bleeding_edge": "", "version": "3.3.1.1", |
1262 "chromium_revision": "", "branch": "3.3", "revision": "234", | 1274 "chromium_revision": "", "branch": "3.3", "revision": "234", |
1263 "review_link": "fake.com", "date": "18:15", "chromium_branch": "", | 1275 "review_link": "fake.com", "date": "18:15", "chromium_branch": "", |
1264 "revision_link": "https://code.google.com/p/v8/source/detail?r=234"}, | 1276 "revision_link": "https://code.google.com/p/v8/source/detail?r=234"}, |
1265 ] | 1277 ] |
1266 self.assertEquals(expected_json, json.loads(FileToText(json_output))) | 1278 self.assertEquals(expected_json, json.loads(FileToText(json_output))) |
1267 | 1279 |
1268 | 1280 |
| 1281 def testBumpUpVersion(self): |
| 1282 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1283 self.WriteFakeVersionFile() |
| 1284 |
| 1285 def ResetVersion(minor, build, patch=0): |
| 1286 return lambda: self.WriteFakeVersionFile(minor=minor, |
| 1287 build=build, |
| 1288 patch=patch) |
| 1289 |
| 1290 self.ExpectGit([ |
| 1291 Git("status -s -uno", ""), |
| 1292 Git("checkout -f bleeding_edge", "", cb=ResetVersion(11, 4)), |
| 1293 Git("pull", ""), |
| 1294 Git("branch", ""), |
| 1295 Git("checkout -f bleeding_edge", ""), |
| 1296 Git("log -1 --format=%H", "latest_hash"), |
| 1297 Git("diff --name-only latest_hash latest_hash^", ""), |
| 1298 Git("checkout -f bleeding_edge", ""), |
| 1299 Git("log --format=%H --grep=\"^git-svn-id: [^@]*@12345 [A-Za-z0-9-]*$\"", |
| 1300 "lkgr_hash"), |
| 1301 Git("checkout -b auto-bump-up-version lkgr_hash", ""), |
| 1302 Git("checkout -f bleeding_edge", ""), |
| 1303 Git("branch", ""), |
| 1304 Git("diff --name-only lkgr_hash lkgr_hash^", ""), |
| 1305 Git("checkout -f master", "", cb=ResetVersion(11, 5)), |
| 1306 Git("pull", ""), |
| 1307 Git("checkout -b auto-bump-up-version bleeding_edge", "", |
| 1308 cb=ResetVersion(11, 4)), |
| 1309 Git("commit -am \"[Auto-roll] Bump up version to 3.11.6.0\n\n" |
| 1310 "TBR=author@chromium.org\"", ""), |
| 1311 Git("cl upload --send-mail --email \"author@chromium.org\" -f", ""), |
| 1312 Git("cl dcommit -f --bypass-hooks", ""), |
| 1313 Git("checkout -f bleeding_edge", ""), |
| 1314 Git("branch", "auto-bump-up-version\n* bleeding_edge"), |
| 1315 Git("branch -D auto-bump-up-version", ""), |
| 1316 ]) |
| 1317 |
| 1318 self.ExpectReadURL([ |
| 1319 URL("https://v8-status.appspot.com/lkgr", "12345"), |
| 1320 URL("https://v8-status.appspot.com/current?format=json", |
| 1321 "{\"message\": \"Tree is open\"}"), |
| 1322 ]) |
| 1323 |
| 1324 BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"]) |
| 1325 |
| 1326 # Test that we bail out if the last change was a version change. |
| 1327 def testBumpUpVersionBailout1(self): |
| 1328 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1329 self._state["latest"] = "latest_hash" |
| 1330 |
| 1331 self.ExpectGit([ |
| 1332 Git("diff --name-only latest_hash latest_hash^", |
| 1333 TEST_CONFIG[VERSION_FILE]), |
| 1334 ]) |
| 1335 |
| 1336 self.assertEquals(1, |
| 1337 self.RunStep(BumpUpVersion, LastChangeBailout, ["--dry_run"])) |
| 1338 |
| 1339 # Test that we bail out if the lkgr was a version change. |
| 1340 def testBumpUpVersionBailout2(self): |
| 1341 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1342 self._state["lkgr"] = "lkgr_hash" |
| 1343 |
| 1344 self.ExpectGit([ |
| 1345 Git("diff --name-only lkgr_hash lkgr_hash^", TEST_CONFIG[VERSION_FILE]), |
| 1346 ]) |
| 1347 |
| 1348 self.assertEquals(1, |
| 1349 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"])) |
| 1350 |
| 1351 # Test that we bail out if the last version is already newer than the lkgr's |
| 1352 # version. |
| 1353 def testBumpUpVersionBailout3(self): |
| 1354 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 1355 self._state["lkgr"] = "lkgr_hash" |
| 1356 self._state["lkgr_version"] = "3.22.4.0" |
| 1357 self._state["latest_version"] = "3.22.5.0" |
| 1358 |
| 1359 self.ExpectGit([ |
| 1360 Git("diff --name-only lkgr_hash lkgr_hash^", ""), |
| 1361 ]) |
| 1362 |
| 1363 self.assertEquals(1, |
| 1364 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"])) |
| 1365 |
| 1366 |
1269 class SystemTest(unittest.TestCase): | 1367 class SystemTest(unittest.TestCase): |
1270 def testReload(self): | 1368 def testReload(self): |
1271 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 1369 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, |
1272 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 1370 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) |
1273 body = step.Reload( | 1371 body = step.Reload( |
1274 """------------------------------------------------------------------------ | 1372 """------------------------------------------------------------------------ |
1275 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 1373 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines |
1276 | 1374 |
1277 Prepare push to trunk. Now working on version 3.23.11. | 1375 Prepare push to trunk. Now working on version 3.23.11. |
1278 | 1376 |
1279 R=danno@chromium.org | 1377 R=danno@chromium.org |
1280 | 1378 |
1281 Review URL: https://codereview.chromium.org/83173002 | 1379 Review URL: https://codereview.chromium.org/83173002 |
1282 | 1380 |
1283 ------------------------------------------------------------------------""") | 1381 ------------------------------------------------------------------------""") |
1284 self.assertEquals( | 1382 self.assertEquals( |
1285 """Prepare push to trunk. Now working on version 3.23.11. | 1383 """Prepare push to trunk. Now working on version 3.23.11. |
1286 | 1384 |
1287 R=danno@chromium.org | 1385 R=danno@chromium.org |
1288 | 1386 |
1289 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1387 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
OLD | NEW |