Chromium Code Reviews| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 def Run(self): | 249 def Run(self): |
| 250 # Restore state. | 250 # Restore state. |
| 251 state_file = "%s-state.json" % self._config[PERSISTFILE_BASENAME] | 251 state_file = "%s-state.json" % self._config[PERSISTFILE_BASENAME] |
| 252 if not self._state and os.path.exists(state_file): | 252 if not self._state and os.path.exists(state_file): |
| 253 self._state.update(json.loads(FileToText(state_file))) | 253 self._state.update(json.loads(FileToText(state_file))) |
| 254 | 254 |
| 255 # Skip step if requirement is not met. | 255 # Skip step if requirement is not met. |
| 256 if self._requires and not self._state.get(self._requires): | 256 if self._requires and not self._state.get(self._requires): |
| 257 return | 257 return |
| 258 | 258 |
| 259 print ">>> Step %d: %s" % (self._number, self._text) | 259 try: |
| 260 self.RunStep() | 260 print ">>> Step %d: %s" % (self._number, self._text) |
|
Jarin
2014/04/02 06:30:40
Why is the printing inside the try block? Can it f
| |
| 261 | 261 return self.RunStep() |
| 262 # Persist state. | 262 finally: |
| 263 TextToFile(json.dumps(self._state), state_file) | 263 # Persist state. |
| 264 TextToFile(json.dumps(self._state), state_file) | |
| 264 | 265 |
| 265 def RunStep(self): # pragma: no cover | 266 def RunStep(self): # pragma: no cover |
| 266 raise NotImplementedError | 267 raise NotImplementedError |
| 267 | 268 |
| 268 def Retry(self, cb, retry_on=None, wait_plan=None): | 269 def Retry(self, cb, retry_on=None, wait_plan=None): |
| 269 """ Retry a function. | 270 """ Retry a function. |
| 270 Params: | 271 Params: |
| 271 cb: The function to retry. | 272 cb: The function to retry. |
| 272 retry_on: A callback that takes the result of the function and returns | 273 retry_on: A callback that takes the result of the function and returns |
| 273 True if the function should be retried. A function throwing an | 274 True if the function should be retried. A function throwing an |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 | 549 |
| 549 state_file = "%s-state.json" % self._config[PERSISTFILE_BASENAME] | 550 state_file = "%s-state.json" % self._config[PERSISTFILE_BASENAME] |
| 550 if options.step == 0 and os.path.exists(state_file): | 551 if options.step == 0 and os.path.exists(state_file): |
| 551 os.remove(state_file) | 552 os.remove(state_file) |
| 552 | 553 |
| 553 steps = [] | 554 steps = [] |
| 554 for (number, step_class) in enumerate(step_classes): | 555 for (number, step_class) in enumerate(step_classes): |
| 555 steps.append(MakeStep(step_class, number, self._state, self._config, | 556 steps.append(MakeStep(step_class, number, self._state, self._config, |
| 556 options, self._side_effect_handler)) | 557 options, self._side_effect_handler)) |
| 557 for step in steps[options.step:]: | 558 for step in steps[options.step:]: |
| 558 step.Run() | 559 if step.Run(): |
| 560 return 1 | |
| 559 return 0 | 561 return 0 |
| 560 | 562 |
| 561 def Run(self, args=None): | 563 def Run(self, args=None): |
| 562 return self.RunSteps(self._Steps(), args) | 564 return self.RunSteps(self._Steps(), args) |
| OLD | NEW |