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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 CHANGELOG_FILE: None, | 51 CHANGELOG_FILE: None, |
52 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 52 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
53 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", | 53 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
54 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 54 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
55 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 55 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
56 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 56 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
57 SETTINGS_LOCATION: None, | 57 SETTINGS_LOCATION: None, |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None): | 61 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, |
| 62 status_password=None): |
62 """Convenience wrapper.""" | 63 """Convenience wrapper.""" |
63 class Options(object): | 64 class Options(object): |
64 pass | 65 pass |
65 options = Options() | 66 options = Options() |
66 options.s = s | 67 options.s = s |
67 options.l = l | 68 options.l = l |
68 options.f = f | 69 options.f = f |
69 options.m = m | 70 options.m = m |
70 options.r = r | 71 options.r = r |
71 options.c = c | 72 options.c = c |
| 73 options.status_password = status_password |
72 return options | 74 return options |
73 | 75 |
74 | 76 |
75 class ToplevelTest(unittest.TestCase): | 77 class ToplevelTest(unittest.TestCase): |
76 def testMakeComment(self): | 78 def testMakeComment(self): |
77 self.assertEquals("# Line 1\n# Line 2\n#", | 79 self.assertEquals("# Line 1\n# Line 2\n#", |
78 MakeComment(" Line 1\n Line 2\n")) | 80 MakeComment(" Line 1\n Line 2\n")) |
79 self.assertEquals("#Line 1\n#Line 2", | 81 self.assertEquals("#Line 1\n#Line 2", |
80 MakeComment("Line 1\n Line 2")) | 82 MakeComment("Line 1\n Line 2")) |
81 | 83 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 "git": GitMock, | 299 "git": GitMock, |
298 "vi": LogMock, | 300 "vi": LogMock, |
299 } | 301 } |
300 | 302 |
301 def Command(self, cmd, args="", prefix="", pipe=True): | 303 def Command(self, cmd, args="", prefix="", pipe=True): |
302 return ScriptTest.MOCKS[cmd](self, cmd, args) | 304 return ScriptTest.MOCKS[cmd](self, cmd, args) |
303 | 305 |
304 def ReadLine(self): | 306 def ReadLine(self): |
305 return self._rl_mock.Call() | 307 return self._rl_mock.Call() |
306 | 308 |
307 def ReadURL(self, url): | 309 def ReadURL(self, url, params): |
308 return self._url_mock.Call(url) | 310 if params is not None: |
| 311 return self._url_mock.Call(url, params) |
| 312 else: |
| 313 return self._url_mock.Call(url) |
309 | 314 |
310 def Sleep(self, seconds): | 315 def Sleep(self, seconds): |
311 pass | 316 pass |
312 | 317 |
313 def GetDate(self): | 318 def GetDate(self): |
314 return "1999-07-31" | 319 return "1999-07-31" |
315 | 320 |
316 def ExpectGit(self, *args): | 321 def ExpectGit(self, *args): |
317 """Convenience wrapper.""" | 322 """Convenience wrapper.""" |
318 self._git_mock.Expect(*args) | 323 self._git_mock.Expect(*args) |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 self.ExpectGit([ | 746 self.ExpectGit([ |
742 ["svn log -1 --oneline", "r101 | Text"], | 747 ["svn log -1 --oneline", "r101 | Text"], |
743 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], | 748 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], |
744 ]) | 749 ]) |
745 | 750 |
746 state = {} | 751 state = {} |
747 self.MakeStep(FetchLatestRevision, state=state).Run() | 752 self.MakeStep(FetchLatestRevision, state=state).Run() |
748 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) | 753 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) |
749 | 754 |
750 def testAutoRoll(self): | 755 def testAutoRoll(self): |
| 756 status_password = self.MakeEmptyTempFile() |
| 757 TextToFile("PW", status_password) |
751 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 758 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
752 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" | 759 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
753 | 760 |
754 self.ExpectReadURL([ | 761 self.ExpectReadURL([ |
755 ["https://v8-status.appspot.com/current?format=json", | 762 ["https://v8-status.appspot.com/current?format=json", |
756 "{\"message\": \"Tree is throttled\"}"], | 763 "{\"message\": \"Tree is throttled\"}"], |
757 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], | 764 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], |
758 ["https://v8-status.appspot.com/lkgr", "100"], | 765 ["https://v8-status.appspot.com/lkgr", "100"], |
| 766 ["https://v8-status.appspot.com/status", |
| 767 ("username=v8-auto-roll%40chromium.org&" |
| 768 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), |
| 769 ""], |
| 770 ["https://v8-status.appspot.com/status", |
| 771 ("username=v8-auto-roll%40chromium.org&" |
| 772 "message=Tree+is+throttled&password=PW"), ""], |
759 ]) | 773 ]) |
760 | 774 |
761 self.ExpectGit([ | 775 self.ExpectGit([ |
762 ["status -s -uno", ""], | 776 ["status -s -uno", ""], |
763 ["status -s -b -uno", "## some_branch\n"], | 777 ["status -s -b -uno", "## some_branch\n"], |
764 ["svn fetch", ""], | 778 ["svn fetch", ""], |
765 ["svn log -1 --oneline", "r101 | Text"], | 779 ["svn log -1 --oneline", "r100 | Text"], |
766 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], | 780 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], |
767 ]) | 781 ]) |
768 | 782 |
769 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) | 783 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions( |
| 784 MakeOptions(status_password=status_password)), self) |
770 | 785 |
771 self.assertEquals("100", self.MakeStep().Restore("lkgr")) | 786 self.assertEquals("100", self.MakeStep().Restore("lkgr")) |
772 self.assertEquals("101", self.MakeStep().Restore("latest")) | 787 self.assertEquals("100", self.MakeStep().Restore("latest")) |
773 | 788 |
774 def testAutoRollStoppedBySettings(self): | 789 def testAutoRollStoppedBySettings(self): |
775 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 790 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
776 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() | 791 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() |
777 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) | 792 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) |
778 | 793 |
779 self.ExpectReadURL([]) | 794 self.ExpectReadURL([]) |
780 | 795 |
781 self.ExpectGit([ | 796 self.ExpectGit([ |
782 ["status -s -uno", ""], | 797 ["status -s -uno", ""], |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 837 |
823 Review URL: https://codereview.chromium.org/83173002 | 838 Review URL: https://codereview.chromium.org/83173002 |
824 | 839 |
825 ------------------------------------------------------------------------""") | 840 ------------------------------------------------------------------------""") |
826 self.assertEquals( | 841 self.assertEquals( |
827 """Prepare push to trunk. Now working on version 3.23.11. | 842 """Prepare push to trunk. Now working on version 3.23.11. |
828 | 843 |
829 R=danno@chromium.org | 844 R=danno@chromium.org |
830 | 845 |
831 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 846 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
OLD | NEW |