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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 # Compare expected and actual arguments. | 209 # Compare expected and actual arguments. |
210 for (expected_arg, actual_arg) in zip(expected_call, args): | 210 for (expected_arg, actual_arg) in zip(expected_call, args): |
211 if expected_arg != actual_arg: | 211 if expected_arg != actual_arg: |
212 raise Exception("Expected: %s - Actual: %s" | 212 raise Exception("Expected: %s - Actual: %s" |
213 % (expected_arg, actual_arg)) | 213 % (expected_arg, actual_arg)) |
214 | 214 |
215 # The expectation list contains a mandatory return value and an optional | 215 # The expectation list contains a mandatory return value and an optional |
216 # callback for checking the context at the time of the call. | 216 # callback for checking the context at the time of the call. |
217 if len(expected_call) == len(args) + 2: | 217 if len(expected_call) == len(args) + 2: |
218 expected_call[len(args) + 1]() | 218 expected_call[len(args) + 1]() |
219 return expected_call[len(args)] | 219 return_value = expected_call[len(args)] |
| 220 |
| 221 # If the return value is an exception, raise it instead of returning. |
| 222 if isinstance(return_value, Exception): |
| 223 raise return_value |
| 224 return return_value |
220 | 225 |
221 def AssertFinished(self): | 226 def AssertFinished(self): |
222 if self._index < len(self._recipe) -1: | 227 if self._index < len(self._recipe) -1: |
223 raise Exception("Called %s too seldom: %d vs. %d" | 228 raise Exception("Called %s too seldom: %d vs. %d" |
224 % (self._name, self._index, len(self._recipe))) | 229 % (self._name, self._index, len(self._recipe))) |
225 | 230 |
226 | 231 |
227 class ScriptTest(unittest.TestCase): | 232 class ScriptTest(unittest.TestCase): |
228 def MakeEmptyTempFile(self): | 233 def MakeEmptyTempFile(self): |
229 handle, name = tempfile.mkstemp() | 234 handle, name = tempfile.mkstemp() |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 267 |
263 def Command(self, cmd, args="", prefix="", pipe=True): | 268 def Command(self, cmd, args="", prefix="", pipe=True): |
264 return ScriptTest.MOCKS[cmd](self, cmd, args) | 269 return ScriptTest.MOCKS[cmd](self, cmd, args) |
265 | 270 |
266 def ReadLine(self): | 271 def ReadLine(self): |
267 return self._rl_mock.Call() | 272 return self._rl_mock.Call() |
268 | 273 |
269 def ReadURL(self, url): | 274 def ReadURL(self, url): |
270 return self._url_mock.Call(url) | 275 return self._url_mock.Call(url) |
271 | 276 |
| 277 def Sleep(self, seconds): |
| 278 pass |
| 279 |
272 def ExpectGit(self, *args): | 280 def ExpectGit(self, *args): |
273 """Convenience wrapper.""" | 281 """Convenience wrapper.""" |
274 self._git_mock.Expect(*args) | 282 self._git_mock.Expect(*args) |
275 | 283 |
276 def ExpectReadline(self, *args): | 284 def ExpectReadline(self, *args): |
277 """Convenience wrapper.""" | 285 """Convenience wrapper.""" |
278 self._rl_mock.Expect(*args) | 286 self._rl_mock.Expect(*args) |
279 | 287 |
280 def ExpectReadURL(self, *args): | 288 def ExpectReadURL(self, *args): |
281 """Convenience wrapper.""" | 289 """Convenience wrapper.""" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 def testPushToTrunkForced(self): | 675 def testPushToTrunkForced(self): |
668 self._PushToTrunk(force=True) | 676 self._PushToTrunk(force=True) |
669 | 677 |
670 def testAutoRoll(self): | 678 def testAutoRoll(self): |
671 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 679 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
672 | 680 |
673 # TODO(machenbach): Get rid of the editor check in automatic mode. | 681 # TODO(machenbach): Get rid of the editor check in automatic mode. |
674 os.environ["EDITOR"] = "vi" | 682 os.environ["EDITOR"] = "vi" |
675 | 683 |
676 self.ExpectReadURL([ | 684 self.ExpectReadURL([ |
| 685 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], |
677 ["https://v8-status.appspot.com/lkgr", "100"], | 686 ["https://v8-status.appspot.com/lkgr", "100"], |
678 ]) | 687 ]) |
679 | 688 |
680 self.ExpectGit([ | 689 self.ExpectGit([ |
681 ["status -s -uno", ""], | 690 ["status -s -uno", ""], |
682 ["status -s -b -uno", "## some_branch\n"], | 691 ["status -s -b -uno", "## some_branch\n"], |
683 ["svn fetch", ""], | 692 ["svn fetch", ""], |
684 ["svn log -1 --oneline", "r101 | Text"], | 693 ["svn log -1 --oneline", "r101 | Text"], |
685 ]) | 694 ]) |
686 | 695 |
(...skipping 25 matching lines...) Expand all Loading... |
712 | 721 |
713 Review URL: https://codereview.chromium.org/83173002 | 722 Review URL: https://codereview.chromium.org/83173002 |
714 | 723 |
715 ------------------------------------------------------------------------""") | 724 ------------------------------------------------------------------------""") |
716 self.assertEquals( | 725 self.assertEquals( |
717 """Prepare push to trunk. Now working on version 3.23.11. | 726 """Prepare push to trunk. Now working on version 3.23.11. |
718 | 727 |
719 R=danno@chromium.org | 728 R=danno@chromium.org |
720 | 729 |
721 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 730 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
OLD | NEW |