Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: tools/push-to-trunk/common_includes.py

Issue 98173003: Mock out date call in push-to-trunk script for testability. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/push-to-trunk/push_to_trunk.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 # disclaimer in the documentation and/or other materials provided 11 # disclaimer in the documentation and/or other materials provided
12 # with the distribution. 12 # with the distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived 14 # contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission. 15 # from this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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 datetime
29 import os 30 import os
30 import re 31 import re
31 import subprocess 32 import subprocess
32 import sys 33 import sys
33 import textwrap 34 import textwrap
34 import time 35 import time
35 import urllib2 36 import urllib2
36 37
37 PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME" 38 PERSISTFILE_BASENAME = "PERSISTFILE_BASENAME"
38 TEMP_BRANCH = "TEMP_BRANCH" 39 TEMP_BRANCH = "TEMP_BRANCH"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return sys.stdin.readline().strip() 196 return sys.stdin.readline().strip()
196 197
197 def ReadURL(self, url): 198 def ReadURL(self, url):
198 # pylint: disable=E1121 199 # pylint: disable=E1121
199 url_fh = urllib2.urlopen(url, None, 60) 200 url_fh = urllib2.urlopen(url, None, 60)
200 try: 201 try:
201 return url_fh.read() 202 return url_fh.read()
202 finally: 203 finally:
203 url_fh.close() 204 url_fh.close()
204 205
205 def Sleep(seconds): 206 def Sleep(self, seconds):
206 time.sleep(seconds) 207 time.sleep(seconds)
207 208
209 def GetDate(self):
210 return datetime.date.today().strftime("%Y-%m-%d")
211
208 DEFAULT_SIDE_EFFECT_HANDLER = SideEffectHandler() 212 DEFAULT_SIDE_EFFECT_HANDLER = SideEffectHandler()
209 213
210 214
211 class Step(object): 215 class Step(object):
212 def __init__(self, text, requires, number, config, state, options, handler): 216 def __init__(self, text, requires, number, config, state, options, handler):
213 self._text = text 217 self._text = text
214 self._requires = requires 218 self._requires = requires
215 self._number = number 219 self._number = number
216 self._config = config 220 self._config = config
217 self._state = state 221 self._state = state
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 283
280 def Editor(self, args): 284 def Editor(self, args):
281 return self._side_effect_handler.Command(os.environ["EDITOR"], args, 285 return self._side_effect_handler.Command(os.environ["EDITOR"], args,
282 pipe=False) 286 pipe=False)
283 287
284 def ReadURL(self, url, retry_on=None, wait_plan=None): 288 def ReadURL(self, url, retry_on=None, wait_plan=None):
285 wait_plan = wait_plan or [3, 60, 600] 289 wait_plan = wait_plan or [3, 60, 600]
286 cmd = lambda: self._side_effect_handler.ReadURL(url) 290 cmd = lambda: self._side_effect_handler.ReadURL(url)
287 return self.Retry(cmd, retry_on, wait_plan) 291 return self.Retry(cmd, retry_on, wait_plan)
288 292
293 def GetDate(self):
294 return self._side_effect_handler.GetDate()
295
289 def Die(self, msg=""): 296 def Die(self, msg=""):
290 if msg != "": 297 if msg != "":
291 print "Error: %s" % msg 298 print "Error: %s" % msg
292 print "Exiting" 299 print "Exiting"
293 raise Exception(msg) 300 raise Exception(msg)
294 301
295 def DieInForcedMode(self, msg=""): 302 def DieInForcedMode(self, msg=""):
296 if self._options and self._options.f: 303 if self._options and self._options.f:
297 msg = msg or "Not implemented in forced mode." 304 msg = msg or "Not implemented in forced mode."
298 self.Die(msg) 305 self.Die(msg)
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 options, 484 options,
478 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER): 485 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER):
479 state = {} 486 state = {}
480 steps = [] 487 steps = []
481 for (number, step_class) in enumerate(step_classes): 488 for (number, step_class) in enumerate(step_classes):
482 steps.append(MakeStep(step_class, number, state, config, 489 steps.append(MakeStep(step_class, number, state, config,
483 options, side_effect_handler)) 490 options, side_effect_handler))
484 491
485 for step in steps[options.s:]: 492 for step in steps[options.s:]:
486 step.Run() 493 step.Run()
OLDNEW
« no previous file with comments | « no previous file | tools/push-to-trunk/push_to_trunk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698