| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
| 58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
| 59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
| 60 SETTINGS_LOCATION: None, | 60 SETTINGS_LOCATION: None, |
| 61 ALREADY_MERGING_SENTINEL_FILE: | 61 ALREADY_MERGING_SENTINEL_FILE: |
| 62 "/tmp/test-merge-to-branch-tempfile-already-merging", | 62 "/tmp/test-merge-to-branch-tempfile-already-merging", |
| 63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", | 63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", |
| 64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", | 64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", |
| 65 } | 65 } |
| 66 | 66 |
| 67 AUTO_ROLL_ARGS = [ |
| 68 "-a", "author@chromium.org", |
| 69 "-c", TEST_CONFIG[CHROMIUM], |
| 70 "-r", "reviewer@chromium.org", |
| 71 ] |
| 72 |
| 67 | 73 |
| 68 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None, | 74 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None, |
| 69 status_password=None, revert_bleeding_edge=None, p=None): | 75 status_password=None, revert_bleeding_edge=None, p=None): |
| 70 """Convenience wrapper.""" | 76 """Convenience wrapper.""" |
| 71 class Options(object): | 77 class Options(object): |
| 72 pass | 78 pass |
| 73 options = Options() | 79 options = Options() |
| 74 options.s = s | 80 options.s = s |
| 75 options.l = l | 81 options.l = l |
| 76 options.f = f | 82 options.f = f |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 # Expected keyboard input in semi-automatic mode: | 739 # Expected keyboard input in semi-automatic mode: |
| 734 if not manual and not force: | 740 if not manual and not force: |
| 735 self.ExpectReadline([ | 741 self.ExpectReadline([ |
| 736 "LGTM", # Enter LGTM for V8 CL. | 742 "LGTM", # Enter LGTM for V8 CL. |
| 737 ]) | 743 ]) |
| 738 | 744 |
| 739 # No keyboard input in forced mode: | 745 # No keyboard input in forced mode: |
| 740 if force: | 746 if force: |
| 741 self.ExpectReadline([]) | 747 self.ExpectReadline([]) |
| 742 | 748 |
| 743 options = MakeOptions(f=force, m=manual, a="author@chromium.org", | 749 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] |
| 744 r="reviewer@chromium.org" if not manual else None, | 750 if force: args.append("-f") |
| 745 c = TEST_CONFIG[CHROMIUM]) | 751 if manual: args.append("-m") |
| 752 else: args += ["-r", "reviewer@chromium.org"] |
| 753 options = push_to_trunk.BuildOptions().parse_args(args) |
| 746 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self) | 754 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self) |
| 747 | 755 |
| 748 deps = FileToText(TEST_CONFIG[DEPS_FILE]) | 756 deps = FileToText(TEST_CONFIG[DEPS_FILE]) |
| 749 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) | 757 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) |
| 750 | 758 |
| 751 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 759 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 752 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) | 760 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 753 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) | 761 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) |
| 754 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) | 762 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) |
| 755 | 763 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 770 self.ExpectGit([ | 778 self.ExpectGit([ |
| 771 ["svn log -1 --oneline", "r101 | Text"], | 779 ["svn log -1 --oneline", "r101 | Text"], |
| 772 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], | 780 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], |
| 773 ]) | 781 ]) |
| 774 | 782 |
| 775 state = {} | 783 state = {} |
| 776 self.MakeStep(FetchLatestRevision, state=state).Run() | 784 self.MakeStep(FetchLatestRevision, state=state).Run() |
| 777 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) | 785 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) |
| 778 | 786 |
| 779 def testAutoRoll(self): | 787 def testAutoRoll(self): |
| 780 status_password = self.MakeEmptyTempFile() | 788 password = self.MakeEmptyTempFile() |
| 781 TextToFile("PW", status_password) | 789 TextToFile("PW", password) |
| 782 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 790 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 783 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 791 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 784 | 792 |
| 785 self.ExpectReadURL([ | 793 self.ExpectReadURL([ |
| 786 ["https://v8-status.appspot.com/current?format=json", | 794 ["https://v8-status.appspot.com/current?format=json", |
| 787 "{\"message\": \"Tree is throttled\"}"], | 795 "{\"message\": \"Tree is throttled\"}"], |
| 788 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], | 796 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], |
| 789 ["https://v8-status.appspot.com/lkgr", "100"], | 797 ["https://v8-status.appspot.com/lkgr", "100"], |
| 790 ["https://v8-status.appspot.com/status", | 798 ["https://v8-status.appspot.com/status", |
| 791 ("username=v8-auto-roll%40chromium.org&" | 799 ("username=v8-auto-roll%40chromium.org&" |
| 792 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), | 800 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), |
| 793 ""], | 801 ""], |
| 794 ["https://v8-status.appspot.com/status", | 802 ["https://v8-status.appspot.com/status", |
| 795 ("username=v8-auto-roll%40chromium.org&" | 803 ("username=v8-auto-roll%40chromium.org&" |
| 796 "message=Tree+is+throttled&password=PW"), ""], | 804 "message=Tree+is+throttled&password=PW"), ""], |
| 797 ]) | 805 ]) |
| 798 | 806 |
| 799 self.ExpectGit([ | 807 self.ExpectGit([ |
| 800 ["status -s -uno", ""], | 808 ["status -s -uno", ""], |
| 801 ["status -s -b -uno", "## some_branch\n"], | 809 ["status -s -b -uno", "## some_branch\n"], |
| 802 ["svn fetch", ""], | 810 ["svn fetch", ""], |
| 803 ["svn log -1 --oneline", "r100 | Text"], | 811 ["svn log -1 --oneline", "r100 | Text"], |
| 804 [("log -1 --format=%H --grep=\"" | 812 [("log -1 --format=%H --grep=\"" |
| 805 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" | 813 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" |
| 806 " svn/trunk"), "push_hash\n"], | 814 " svn/trunk"), "push_hash\n"], |
| 807 ["svn find-rev push_hash", "65"], | 815 ["svn find-rev push_hash", "65"], |
| 808 ]) | 816 ]) |
| 809 | 817 |
| 810 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions( | 818 options = auto_roll.BuildOptions().parse_args( |
| 811 MakeOptions(status_password=status_password)), self) | 819 AUTO_ROLL_ARGS + ["--status-password", password]) |
| 820 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self) |
| 812 | 821 |
| 813 state = json.loads(FileToText("%s-state.json" | 822 state = json.loads(FileToText("%s-state.json" |
| 814 % TEST_CONFIG[PERSISTFILE_BASENAME])) | 823 % TEST_CONFIG[PERSISTFILE_BASENAME])) |
| 815 | 824 |
| 816 self.assertEquals("100", state["lkgr"]) | 825 self.assertEquals("100", state["lkgr"]) |
| 817 self.assertEquals("100", state["latest"]) | 826 self.assertEquals("100", state["latest"]) |
| 818 | 827 |
| 819 def testAutoRollStoppedBySettings(self): | 828 def testAutoRollStoppedBySettings(self): |
| 820 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 829 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 821 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() | 830 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() |
| 822 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) | 831 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) |
| 823 | 832 |
| 824 self.ExpectReadURL([]) | 833 self.ExpectReadURL([]) |
| 825 | 834 |
| 826 self.ExpectGit([ | 835 self.ExpectGit([ |
| 827 ["status -s -uno", ""], | 836 ["status -s -uno", ""], |
| 828 ["status -s -b -uno", "## some_branch\n"], | 837 ["status -s -b -uno", "## some_branch\n"], |
| 829 ["svn fetch", ""], | 838 ["svn fetch", ""], |
| 830 ]) | 839 ]) |
| 831 | 840 |
| 841 options = auto_roll.BuildOptions().parse_args(AUTO_ROLL_ARGS) |
| 832 def RunAutoRoll(): | 842 def RunAutoRoll(): |
| 833 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) | 843 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self) |
| 834 self.assertRaises(Exception, RunAutoRoll) | 844 self.assertRaises(Exception, RunAutoRoll) |
| 835 | 845 |
| 836 def testAutoRollStoppedByTreeStatus(self): | 846 def testAutoRollStoppedByTreeStatus(self): |
| 837 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 847 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 838 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 848 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 839 | 849 |
| 840 self.ExpectReadURL([ | 850 self.ExpectReadURL([ |
| 841 ["https://v8-status.appspot.com/current?format=json", | 851 ["https://v8-status.appspot.com/current?format=json", |
| 842 "{\"message\": \"Tree is throttled (no push)\"}"], | 852 "{\"message\": \"Tree is throttled (no push)\"}"], |
| 843 ]) | 853 ]) |
| 844 | 854 |
| 845 self.ExpectGit([ | 855 self.ExpectGit([ |
| 846 ["status -s -uno", ""], | 856 ["status -s -uno", ""], |
| 847 ["status -s -b -uno", "## some_branch\n"], | 857 ["status -s -b -uno", "## some_branch\n"], |
| 848 ["svn fetch", ""], | 858 ["svn fetch", ""], |
| 849 ]) | 859 ]) |
| 850 | 860 |
| 861 options = auto_roll.BuildOptions().parse_args(AUTO_ROLL_ARGS) |
| 851 def RunAutoRoll(): | 862 def RunAutoRoll(): |
| 852 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) | 863 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self) |
| 853 self.assertRaises(Exception, RunAutoRoll) | 864 self.assertRaises(Exception, RunAutoRoll) |
| 854 | 865 |
| 855 def testMergeToBranch(self): | 866 def testMergeToBranch(self): |
| 856 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() | 867 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() |
| 857 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 868 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 858 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 869 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 859 os.environ["EDITOR"] = "vi" | 870 os.environ["EDITOR"] = "vi" |
| 860 extra_patch = self.MakeEmptyTempFile() | 871 extra_patch = self.MakeEmptyTempFile() |
| 861 | 872 |
| 862 def VerifyPatch(patch): | 873 def VerifyPatch(patch): |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], | 970 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], |
| 960 ]) | 971 ]) |
| 961 | 972 |
| 962 self.ExpectReadline([ | 973 self.ExpectReadline([ |
| 963 "Y", # Automatically add corresponding ports (34567, 56789)? | 974 "Y", # Automatically add corresponding ports (34567, 56789)? |
| 964 "Y", # Automatically increment patch level? | 975 "Y", # Automatically increment patch level? |
| 965 "reviewer@chromium.org", # V8 reviewer. | 976 "reviewer@chromium.org", # V8 reviewer. |
| 966 "LGTM", # Enter LGTM for V8 CL. | 977 "LGTM", # Enter LGTM for V8 CL. |
| 967 ]) | 978 ]) |
| 968 | 979 |
| 969 options = MakeOptions(p=extra_patch, f=True) | |
| 970 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS | 980 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS |
| 971 # ports of r12345. r56789 is the MIPS port of r34567. | 981 # ports of r12345. r56789 is the MIPS port of r34567. |
| 972 args = ["trunk", "12345", "23456", "34567"] | 982 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456", |
| 973 self.assertTrue(merge_to_branch.ProcessOptions(options, args)) | 983 "34567"] |
| 984 options = merge_to_branch.BuildOptions().parse_args(args) |
| 985 self.assertTrue(merge_to_branch.ProcessOptions(options)) |
| 974 | 986 |
| 975 # The first run of the script stops because of the svn being down. | 987 # The first run of the script stops because of the svn being down. |
| 976 self.assertRaises(GitFailedException, | 988 self.assertRaises(GitFailedException, |
| 977 lambda: RunMergeToBranch(TEST_CONFIG, | 989 lambda: RunMergeToBranch(TEST_CONFIG, |
| 978 MergeToBranchOptions(options, args), | 990 MergeToBranchOptions(options), |
| 979 self)) | 991 self)) |
| 980 | 992 |
| 981 # Test that state recovery after restarting the script works. | 993 # Test that state recovery after restarting the script works. |
| 982 options.s = 3 | 994 options.s = 3 |
| 983 RunMergeToBranch(TEST_CONFIG, MergeToBranchOptions(options, args), self) | 995 RunMergeToBranch(TEST_CONFIG, MergeToBranchOptions(options), self) |
| 984 | 996 |
| 985 | 997 |
| 986 class SystemTest(unittest.TestCase): | 998 class SystemTest(unittest.TestCase): |
| 987 def testReload(self): | 999 def testReload(self): |
| 988 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 1000 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, |
| 989 options=CommonOptions(MakeOptions()), | 1001 options=CommonOptions(MakeOptions()), |
| 990 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 1002 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) |
| 991 body = step.Reload( | 1003 body = step.Reload( |
| 992 """------------------------------------------------------------------------ | 1004 """------------------------------------------------------------------------ |
| 993 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 1005 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines |
| 994 | 1006 |
| 995 Prepare push to trunk. Now working on version 3.23.11. | 1007 Prepare push to trunk. Now working on version 3.23.11. |
| 996 | 1008 |
| 997 R=danno@chromium.org | 1009 R=danno@chromium.org |
| 998 | 1010 |
| 999 Review URL: https://codereview.chromium.org/83173002 | 1011 Review URL: https://codereview.chromium.org/83173002 |
| 1000 | 1012 |
| 1001 ------------------------------------------------------------------------""") | 1013 ------------------------------------------------------------------------""") |
| 1002 self.assertEquals( | 1014 self.assertEquals( |
| 1003 """Prepare push to trunk. Now working on version 3.23.11. | 1015 """Prepare push to trunk. Now working on version 3.23.11. |
| 1004 | 1016 |
| 1005 R=danno@chromium.org | 1017 R=danno@chromium.org |
| 1006 | 1018 |
| 1007 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1019 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |