| 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 13 matching lines...) Expand all Loading... |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import os | 29 import os |
| 30 import tempfile | 30 import tempfile |
| 31 import traceback | 31 import traceback |
| 32 import unittest | 32 import unittest |
| 33 | 33 |
| 34 import auto_roll | 34 import auto_push |
| 35 from auto_roll import CheckLastPush | 35 from auto_push import CheckLastPush |
| 36 from auto_roll import SETTINGS_LOCATION | 36 from auto_push import SETTINGS_LOCATION |
| 37 import common_includes | 37 import common_includes |
| 38 from common_includes import * | 38 from common_includes import * |
| 39 import merge_to_branch | 39 import merge_to_branch |
| 40 from merge_to_branch import * | 40 from merge_to_branch import * |
| 41 import push_to_trunk | 41 import push_to_trunk |
| 42 from push_to_trunk import * | 42 from push_to_trunk import * |
| 43 import chromium_roll | 43 import chromium_roll |
| 44 from chromium_roll import CHROMIUM | 44 from chromium_roll import CHROMIUM |
| 45 from chromium_roll import DEPS_FILE | 45 from chromium_roll import DEPS_FILE |
| 46 from chromium_roll import ChromiumRoll | 46 from chromium_roll import ChromiumRoll |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 60 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
| 61 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 61 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
| 62 SETTINGS_LOCATION: None, | 62 SETTINGS_LOCATION: None, |
| 63 ALREADY_MERGING_SENTINEL_FILE: | 63 ALREADY_MERGING_SENTINEL_FILE: |
| 64 "/tmp/test-merge-to-branch-tempfile-already-merging", | 64 "/tmp/test-merge-to-branch-tempfile-already-merging", |
| 65 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", | 65 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", |
| 66 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", | 66 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", |
| 67 } | 67 } |
| 68 | 68 |
| 69 | 69 |
| 70 AUTO_ROLL_ARGS = [ | 70 AUTO_PUSH_ARGS = [ |
| 71 "-a", "author@chromium.org", | 71 "-a", "author@chromium.org", |
| 72 "-c", TEST_CONFIG[CHROMIUM], | |
| 73 "-r", "reviewer@chromium.org", | 72 "-r", "reviewer@chromium.org", |
| 74 ] | 73 ] |
| 75 | 74 |
| 76 | 75 |
| 77 class ToplevelTest(unittest.TestCase): | 76 class ToplevelTest(unittest.TestCase): |
| 78 def testMakeComment(self): | 77 def testMakeComment(self): |
| 79 self.assertEquals("# Line 1\n# Line 2\n#", | 78 self.assertEquals("# Line 1\n# Line 2\n#", |
| 80 MakeComment(" Line 1\n Line 2\n")) | 79 MakeComment(" Line 1\n Line 2\n")) |
| 81 self.assertEquals("#Line 1\n#Line 2", | 80 self.assertEquals("#Line 1\n#Line 2", |
| 82 MakeComment("Line 1\n Line 2")) | 81 MakeComment("Line 1\n Line 2")) |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 self.ExpectGit([ | 832 self.ExpectGit([ |
| 834 Git(("log -1 --format=%H --grep=" | 833 Git(("log -1 --format=%H --grep=" |
| 835 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " | 834 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " |
| 836 "svn/trunk"), "hash2\n"), | 835 "svn/trunk"), "hash2\n"), |
| 837 Git("log -1 --format=%s hash2", | 836 Git("log -1 --format=%s hash2", |
| 838 "Version 3.4.5 (based on bleeding_edge revision r99)\n"), | 837 "Version 3.4.5 (based on bleeding_edge revision r99)\n"), |
| 839 ]) | 838 ]) |
| 840 | 839 |
| 841 self._state["lkgr"] = "101" | 840 self._state["lkgr"] = "101" |
| 842 | 841 |
| 843 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll, | 842 self.assertRaises(Exception, lambda: self.RunStep(auto_push.AutoPush, |
| 844 CheckLastPush, | 843 CheckLastPush, |
| 845 AUTO_ROLL_ARGS)) | 844 AUTO_PUSH_ARGS)) |
| 846 | 845 |
| 847 def testAutoRoll(self): | 846 def testAutoPush(self): |
| 848 password = self.MakeEmptyTempFile() | |
| 849 TextToFile("PW", password) | |
| 850 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 847 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 851 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 848 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 852 | 849 |
| 853 self.ExpectReadURL([ | 850 self.ExpectReadURL([ |
| 854 URL("https://v8-status.appspot.com/current?format=json", | 851 URL("https://v8-status.appspot.com/current?format=json", |
| 855 "{\"message\": \"Tree is throttled\"}"), | 852 "{\"message\": \"Tree is throttled\"}"), |
| 856 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")), | 853 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")), |
| 857 URL("https://v8-status.appspot.com/lkgr", "100"), | 854 URL("https://v8-status.appspot.com/lkgr", "100"), |
| 858 URL("https://v8-status.appspot.com/status", | |
| 859 ("username=v8-auto-roll%40chromium.org&" | |
| 860 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), ""), | |
| 861 URL("https://v8-status.appspot.com/status", | |
| 862 ("username=v8-auto-roll%40chromium.org&" | |
| 863 "message=Tree+is+throttled&password=PW"), ""), | |
| 864 ]) | 855 ]) |
| 865 | 856 |
| 866 self.ExpectGit([ | 857 self.ExpectGit([ |
| 867 Git("status -s -uno", ""), | 858 Git("status -s -uno", ""), |
| 868 Git("status -s -b -uno", "## some_branch\n"), | 859 Git("status -s -b -uno", "## some_branch\n"), |
| 869 Git("svn fetch", ""), | 860 Git("svn fetch", ""), |
| 870 Git(("log -1 --format=%H --grep=\"" | 861 Git(("log -1 --format=%H --grep=\"" |
| 871 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" | 862 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" |
| 872 " svn/trunk"), "push_hash\n"), | 863 " svn/trunk"), "push_hash\n"), |
| 873 Git("log -1 --format=%s push_hash", | 864 Git("log -1 --format=%s push_hash", |
| 874 "Version 3.4.5 (based on bleeding_edge revision r79)\n"), | 865 "Version 3.4.5 (based on bleeding_edge revision r79)\n"), |
| 875 ]) | 866 ]) |
| 876 | 867 |
| 877 auto_roll.AutoRoll(TEST_CONFIG, self).Run( | 868 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"]) |
| 878 AUTO_ROLL_ARGS + ["--status-password", password, "--push"]) | |
| 879 | 869 |
| 880 state = json.loads(FileToText("%s-state.json" | 870 state = json.loads(FileToText("%s-state.json" |
| 881 % TEST_CONFIG[PERSISTFILE_BASENAME])) | 871 % TEST_CONFIG[PERSISTFILE_BASENAME])) |
| 882 | 872 |
| 883 self.assertEquals("100", state["lkgr"]) | 873 self.assertEquals("100", state["lkgr"]) |
| 884 | 874 |
| 885 def testAutoRollStoppedBySettings(self): | 875 def testAutoPushStoppedBySettings(self): |
| 886 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 876 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 887 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() | 877 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() |
| 888 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) | 878 TextToFile("{\"enable_auto_push\": false}", TEST_CONFIG[SETTINGS_LOCATION]) |
| 889 | 879 |
| 890 self.ExpectReadURL([]) | 880 self.ExpectReadURL([]) |
| 891 | 881 |
| 892 self.ExpectGit([ | 882 self.ExpectGit([ |
| 893 Git("status -s -uno", ""), | 883 Git("status -s -uno", ""), |
| 894 Git("status -s -b -uno", "## some_branch\n"), | 884 Git("status -s -b -uno", "## some_branch\n"), |
| 895 Git("svn fetch", ""), | 885 Git("svn fetch", ""), |
| 896 ]) | 886 ]) |
| 897 | 887 |
| 898 def RunAutoRoll(): | 888 def RunAutoPush(): |
| 899 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) | 889 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS) |
| 900 self.assertRaises(Exception, RunAutoRoll) | 890 self.assertRaises(Exception, RunAutoPush) |
| 901 | 891 |
| 902 def testAutoRollStoppedByTreeStatus(self): | 892 def testAutoPushStoppedByTreeStatus(self): |
| 903 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 893 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 904 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 894 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 905 | 895 |
| 906 self.ExpectReadURL([ | 896 self.ExpectReadURL([ |
| 907 URL("https://v8-status.appspot.com/current?format=json", | 897 URL("https://v8-status.appspot.com/current?format=json", |
| 908 "{\"message\": \"Tree is throttled (no push)\"}"), | 898 "{\"message\": \"Tree is throttled (no push)\"}"), |
| 909 ]) | 899 ]) |
| 910 | 900 |
| 911 self.ExpectGit([ | 901 self.ExpectGit([ |
| 912 Git("status -s -uno", ""), | 902 Git("status -s -uno", ""), |
| 913 Git("status -s -b -uno", "## some_branch\n"), | 903 Git("status -s -b -uno", "## some_branch\n"), |
| 914 Git("svn fetch", ""), | 904 Git("svn fetch", ""), |
| 915 ]) | 905 ]) |
| 916 | 906 |
| 917 def RunAutoRoll(): | 907 def RunAutoPush(): |
| 918 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS) | 908 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS) |
| 919 self.assertRaises(Exception, RunAutoRoll) | 909 self.assertRaises(Exception, RunAutoPush) |
| 920 | 910 |
| 921 def testMergeToBranch(self): | 911 def testMergeToBranch(self): |
| 922 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() | 912 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() |
| 923 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 913 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 924 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() | 914 TEST_CONFIG[VERSION_FILE] = self.MakeEmptyTempFile() |
| 925 self.WriteFakeVersionFile(build=5) | 915 self.WriteFakeVersionFile(build=5) |
| 926 os.environ["EDITOR"] = "vi" | 916 os.environ["EDITOR"] = "vi" |
| 927 extra_patch = self.MakeEmptyTempFile() | 917 extra_patch = self.MakeEmptyTempFile() |
| 928 | 918 |
| 929 def VerifyPatch(patch): | 919 def VerifyPatch(patch): |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 | 1051 |
| 1062 Review URL: https://codereview.chromium.org/83173002 | 1052 Review URL: https://codereview.chromium.org/83173002 |
| 1063 | 1053 |
| 1064 ------------------------------------------------------------------------""") | 1054 ------------------------------------------------------------------------""") |
| 1065 self.assertEquals( | 1055 self.assertEquals( |
| 1066 """Prepare push to trunk. Now working on version 3.23.11. | 1056 """Prepare push to trunk. Now working on version 3.23.11. |
| 1067 | 1057 |
| 1068 R=danno@chromium.org | 1058 R=danno@chromium.org |
| 1069 | 1059 |
| 1070 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1060 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |