| 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 23 matching lines...) Expand all Loading... |
| 34 import auto_roll | 34 import auto_roll |
| 35 from auto_roll import CheckLastPush | 35 from auto_roll import CheckLastPush |
| 36 from auto_roll import FetchLatestRevision | 36 from auto_roll import FetchLatestRevision |
| 37 from auto_roll import SETTINGS_LOCATION | 37 from auto_roll import SETTINGS_LOCATION |
| 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 |
| 45 from chromium_roll import CHROMIUM |
| 46 from chromium_roll import DEPS_FILE |
| 47 from chromium_roll import ChromiumRoll |
| 44 | 48 |
| 45 | 49 |
| 46 TEST_CONFIG = { | 50 TEST_CONFIG = { |
| 47 BRANCHNAME: "test-prepare-push", | 51 BRANCHNAME: "test-prepare-push", |
| 48 TRUNKBRANCH: "test-trunk-push", | 52 TRUNKBRANCH: "test-trunk-push", |
| 49 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 53 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
| 50 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 54 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", |
| 51 DOT_GIT_LOCATION: None, | 55 DOT_GIT_LOCATION: None, |
| 52 VERSION_FILE: None, | 56 VERSION_FILE: None, |
| 53 CHANGELOG_FILE: None, | 57 CHANGELOG_FILE: None, |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 def _PushToTrunk(self, force=False, manual=False): | 635 def _PushToTrunk(self, force=False, manual=False): |
| 632 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 636 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 633 | 637 |
| 634 # The version file on bleeding edge has build level 5, while the version | 638 # The version file on bleeding edge has build level 5, while the version |
| 635 # file from trunk has build level 4. | 639 # file from trunk has build level 4. |
| 636 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 640 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 637 self.WriteFakeVersionFile(build=5) | 641 self.WriteFakeVersionFile(build=5) |
| 638 | 642 |
| 639 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 643 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 640 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 644 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 641 if not os.path.exists(TEST_CONFIG[CHROMIUM]): | |
| 642 os.makedirs(TEST_CONFIG[CHROMIUM]) | |
| 643 bleeding_edge_change_log = "2014-03-17: Sentinel\n" | 645 bleeding_edge_change_log = "2014-03-17: Sentinel\n" |
| 644 TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE]) | 646 TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE]) |
| 645 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", | |
| 646 TEST_CONFIG[DEPS_FILE]) | |
| 647 os.environ["EDITOR"] = "vi" | 647 os.environ["EDITOR"] = "vi" |
| 648 | 648 |
| 649 def ResetChangeLog(): | 649 def ResetChangeLog(): |
| 650 """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog', | 650 """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog', |
| 651 the ChangLog will be reset to its content on trunk.""" | 651 the ChangLog will be reset to its content on trunk.""" |
| 652 trunk_change_log = """1999-04-05: Version 3.22.4 | 652 trunk_change_log = """1999-04-05: Version 3.22.4 |
| 653 | 653 |
| 654 Performance and stability improvements on all platforms.\n""" | 654 Performance and stability improvements on all platforms.\n""" |
| 655 TextToFile(trunk_change_log, TEST_CONFIG[CHANGELOG_FILE]) | 655 TextToFile(trunk_change_log, TEST_CONFIG[CHANGELOG_FILE]) |
| 656 | 656 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 682 | 682 |
| 683 Performance and stability improvements on all platforms. | 683 Performance and stability improvements on all platforms. |
| 684 | 684 |
| 685 | 685 |
| 686 1999-04-05: Version 3.22.4 | 686 1999-04-05: Version 3.22.4 |
| 687 | 687 |
| 688 Performance and stability improvements on all platforms.\n""", | 688 Performance and stability improvements on all platforms.\n""", |
| 689 change_log) | 689 change_log) |
| 690 | 690 |
| 691 force_flag = " -f" if not manual else "" | 691 force_flag = " -f" if not manual else "" |
| 692 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" | |
| 693 self.ExpectGit([ | 692 self.ExpectGit([ |
| 694 Git("status -s -uno", ""), | 693 Git("status -s -uno", ""), |
| 695 Git("status -s -b -uno", "## some_branch\n"), | 694 Git("status -s -b -uno", "## some_branch\n"), |
| 696 Git("svn fetch", ""), | 695 Git("svn fetch", ""), |
| 697 Git("branch", " branch1\n* branch2\n"), | 696 Git("branch", " branch1\n* branch2\n"), |
| 698 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""), | 697 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 699 Git("branch", " branch1\n* branch2\n"), | 698 Git("branch", " branch1\n* branch2\n"), |
| 700 Git("branch", " branch1\n* branch2\n"), | 699 Git("branch", " branch1\n* branch2\n"), |
| 701 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), | 700 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""), |
| 702 Git("svn find-rev r123455", "push_hash\n"), | 701 Git("svn find-rev r123455", "push_hash\n"), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 721 cb=ResetToTrunk), | 720 cb=ResetToTrunk), |
| 722 Git("apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), | 721 Git("apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), |
| 723 Git("checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "", | 722 Git("checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "", |
| 724 cb=ResetChangeLog), | 723 cb=ResetChangeLog), |
| 725 Git("checkout -f svn/trunk -- %s" % TEST_CONFIG[VERSION_FILE], "", | 724 Git("checkout -f svn/trunk -- %s" % TEST_CONFIG[VERSION_FILE], "", |
| 726 cb=self.WriteFakeVersionFile), | 725 cb=self.WriteFakeVersionFile), |
| 727 Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", | 726 Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", |
| 728 cb=CheckSVNCommit), | 727 cb=CheckSVNCommit), |
| 729 Git("svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"), | 728 Git("svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"), |
| 730 Git("svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), | 729 Git("svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), |
| 731 Git("status -s -uno", ""), | |
| 732 Git("checkout -f master", ""), | |
| 733 Git("pull", ""), | |
| 734 Git("checkout -b v8-roll-123456", ""), | |
| 735 Git(("commit -am \"Update V8 to version 3.22.5 " | |
| 736 "(based on bleeding_edge revision r123455).\n\n" | |
| 737 "TBR=reviewer@chromium.org\""), | |
| 738 ""), | |
| 739 Git(("cl upload --send-mail --email \"author@chromium.org\"%s" | |
| 740 % force_flag), ""), | |
| 741 Git("checkout -f some_branch", ""), | 730 Git("checkout -f some_branch", ""), |
| 742 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""), | 731 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""), |
| 743 Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), | 732 Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), |
| 744 Git("branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), | 733 Git("branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), |
| 745 ]) | 734 ]) |
| 746 | 735 |
| 747 # Expected keyboard input in manual mode: | 736 # Expected keyboard input in manual mode: |
| 748 if manual: | 737 if manual: |
| 749 self.ExpectReadline([ | 738 self.ExpectReadline([ |
| 750 RL("Y"), # Confirm last push. | 739 RL("Y"), # Confirm last push. |
| 751 RL(""), # Open editor. | 740 RL(""), # Open editor. |
| 752 RL("Y"), # Increment build number. | 741 RL("Y"), # Increment build number. |
| 753 RL("Y"), # Sanity check. | 742 RL("Y"), # Sanity check. |
| 754 RL("reviewer@chromium.org"), # Chromium reviewer. | |
| 755 ]) | 743 ]) |
| 756 | 744 |
| 757 # Expected keyboard input in semi-automatic mode and forced mode: | 745 # Expected keyboard input in semi-automatic mode and forced mode: |
| 758 if not manual: | 746 if not manual: |
| 759 self.ExpectReadline([]) | 747 self.ExpectReadline([]) |
| 760 | 748 |
| 761 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM], | 749 args = ["-a", "author@chromium.org", "--revision", "123455"] |
| 762 "--revision", "123455"] | |
| 763 if force: args.append("-f") | 750 if force: args.append("-f") |
| 764 if manual: args.append("-m") | 751 if manual: args.append("-m") |
| 765 else: args += ["-r", "reviewer@chromium.org"] | 752 else: args += ["-r", "reviewer@chromium.org"] |
| 766 PushToTrunk(TEST_CONFIG, self).Run(args) | 753 PushToTrunk(TEST_CONFIG, self).Run(args) |
| 767 | 754 |
| 768 deps = FileToText(TEST_CONFIG[DEPS_FILE]) | |
| 769 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) | |
| 770 | |
| 771 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 755 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 772 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) | 756 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 773 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) | 757 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) |
| 774 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) | 758 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) |
| 775 | 759 |
| 776 # Note: The version file is on build number 5 again in the end of this test | 760 # Note: The version file is on build number 5 again in the end of this test |
| 777 # since the git command that merges to the bleeding edge branch is mocked | 761 # since the git command that merges to the bleeding edge branch is mocked |
| 778 # out. | 762 # out. |
| 779 | 763 |
| 780 def testPushToTrunkManual(self): | 764 def testPushToTrunkManual(self): |
| 781 self._PushToTrunk(manual=True) | 765 self._PushToTrunk(manual=True) |
| 782 | 766 |
| 783 def testPushToTrunkSemiAutomatic(self): | 767 def testPushToTrunkSemiAutomatic(self): |
| 784 self._PushToTrunk() | 768 self._PushToTrunk() |
| 785 | 769 |
| 786 def testPushToTrunkForced(self): | 770 def testPushToTrunkForced(self): |
| 787 self._PushToTrunk(force=True) | 771 self._PushToTrunk(force=True) |
| 788 | 772 |
| 773 |
| 774 def _ChromiumRoll(self, force=False, manual=False): |
| 775 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 776 if not os.path.exists(TEST_CONFIG[CHROMIUM]): |
| 777 os.makedirs(TEST_CONFIG[CHROMIUM]) |
| 778 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
| 779 TEST_CONFIG[DEPS_FILE]) |
| 780 |
| 781 os.environ["EDITOR"] = "vi" |
| 782 force_flag = " -f" if not manual else "" |
| 783 self.ExpectGit([ |
| 784 Git("status -s -uno", ""), |
| 785 Git("status -s -b -uno", "## some_branch\n"), |
| 786 Git("svn fetch", ""), |
| 787 Git(("log -1 --format=%H --grep=" |
| 788 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " |
| 789 "svn/trunk"), "push_hash\n"), |
| 790 Git("svn find-rev push_hash", "123455\n"), |
| 791 Git("log -1 --format=%s push_hash", |
| 792 "Version 3.22.5 (based on bleeding_edge revision r123454)\n"), |
| 793 Git("status -s -uno", ""), |
| 794 Git("checkout -f master", ""), |
| 795 Git("pull", ""), |
| 796 Git("checkout -b v8-roll-123455", ""), |
| 797 Git(("commit -am \"Update V8 to version 3.22.5 " |
| 798 "(based on bleeding_edge revision r123454).\n\n" |
| 799 "TBR=reviewer@chromium.org\""), |
| 800 ""), |
| 801 Git(("cl upload --send-mail --email \"author@chromium.org\"%s" |
| 802 % force_flag), ""), |
| 803 ]) |
| 804 |
| 805 # Expected keyboard input in manual mode: |
| 806 if manual: |
| 807 self.ExpectReadline([ |
| 808 RL("reviewer@chromium.org"), # Chromium reviewer. |
| 809 ]) |
| 810 |
| 811 # Expected keyboard input in semi-automatic mode and forced mode: |
| 812 if not manual: |
| 813 self.ExpectReadline([]) |
| 814 |
| 815 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] |
| 816 if force: args.append("-f") |
| 817 if manual: args.append("-m") |
| 818 else: args += ["-r", "reviewer@chromium.org"] |
| 819 ChromiumRoll(TEST_CONFIG, self).Run(args) |
| 820 |
| 821 deps = FileToText(TEST_CONFIG[DEPS_FILE]) |
| 822 self.assertTrue(re.search("\"v8_revision\": \"123455\"", deps)) |
| 823 |
| 824 def testChromiumRollManual(self): |
| 825 self._ChromiumRoll(manual=True) |
| 826 |
| 827 def testChromiumRollSemiAutomatic(self): |
| 828 self._ChromiumRoll() |
| 829 |
| 830 def testChromiumRollForced(self): |
| 831 self._ChromiumRoll(force=True) |
| 832 |
| 789 def testCheckLastPushRecently(self): | 833 def testCheckLastPushRecently(self): |
| 790 self.ExpectGit([ | 834 self.ExpectGit([ |
| 791 Git("svn log -1 --oneline", "r101 | Text"), | 835 Git("svn log -1 --oneline", "r101 | Text"), |
| 792 Git("svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."), | 836 Git("svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."), |
| 793 ]) | 837 ]) |
| 794 | 838 |
| 795 self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS) | 839 self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS) |
| 796 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll, | 840 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll, |
| 797 CheckLastPush, | 841 CheckLastPush, |
| 798 AUTO_ROLL_ARGS)) | 842 AUTO_ROLL_ARGS)) |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 | 1059 |
| 1016 Review URL: https://codereview.chromium.org/83173002 | 1060 Review URL: https://codereview.chromium.org/83173002 |
| 1017 | 1061 |
| 1018 ------------------------------------------------------------------------""") | 1062 ------------------------------------------------------------------------""") |
| 1019 self.assertEquals( | 1063 self.assertEquals( |
| 1020 """Prepare push to trunk. Now working on version 3.23.11. | 1064 """Prepare push to trunk. Now working on version 3.23.11. |
| 1021 | 1065 |
| 1022 R=danno@chromium.org | 1066 R=danno@chromium.org |
| 1023 | 1067 |
| 1024 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1068 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |