| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import pipes | 8 import pipes |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 def SpawnCmd(command, stdout=None, cwd=CHROME_SRC): | 39 def SpawnCmd(command, stdout=None, cwd=CHROME_SRC): |
| 40 """Spawn a process without waiting for termination.""" | 40 """Spawn a process without waiting for termination.""" |
| 41 print '>', CommandToString(command) | 41 print '>', CommandToString(command) |
| 42 sys.stdout.flush() | 42 sys.stdout.flush() |
| 43 if TESTING: | 43 if TESTING: |
| 44 class MockPopen(object): | 44 class MockPopen(object): |
| 45 @staticmethod | 45 @staticmethod |
| 46 def wait(): | 46 def wait(): |
| 47 return 0 | 47 return 0 |
| 48 @staticmethod |
| 49 def communicate(): |
| 50 return '', '' |
| 48 return MockPopen() | 51 return MockPopen() |
| 49 return subprocess.Popen(command, cwd=cwd, stdout=stdout) | 52 return subprocess.Popen(command, cwd=cwd, stdout=stdout) |
| 50 | 53 |
| 51 | 54 |
| 52 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, | 55 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, |
| 53 warning_code=constants.WARNING_EXIT_CODE, stdout=None, | 56 warning_code=constants.WARNING_EXIT_CODE, stdout=None, |
| 54 cwd=CHROME_SRC): | 57 cwd=CHROME_SRC): |
| 55 """Run a command relative to the chrome source root.""" | 58 """Run a command relative to the chrome source root.""" |
| 56 code = SpawnCmd(command, stdout, cwd).wait() | 59 code = SpawnCmd(command, stdout, cwd).wait() |
| 57 print '<', CommandToString(command) | 60 print '<', CommandToString(command) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 88 | 91 |
| 89 def RunSteps(steps, step_cmds, options): | 92 def RunSteps(steps, step_cmds, options): |
| 90 unknown_steps = set(steps) - set(step for step, _ in step_cmds) | 93 unknown_steps = set(steps) - set(step for step, _ in step_cmds) |
| 91 if unknown_steps: | 94 if unknown_steps: |
| 92 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps) | 95 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps) |
| 93 sys.exit(1) | 96 sys.exit(1) |
| 94 | 97 |
| 95 for step, cmd in step_cmds: | 98 for step, cmd in step_cmds: |
| 96 if step in steps: | 99 if step in steps: |
| 97 cmd(options) | 100 cmd(options) |
| OLD | NEW |