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

Side by Side Diff: build/android/buildbot/bb_utils.py

Issue 21647002: [Android Buildbot] Make RunCmd execute command in a dir of choice. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 CHROME_SRC = os.path.abspath( 24 CHROME_SRC = os.path.abspath(
25 os.path.join(os.path.dirname(__file__), '..', '..', '..')) 25 os.path.join(os.path.dirname(__file__), '..', '..', '..'))
26 26
27 GOMA_DIR = os.environ.get('GOMA_DIR', os.path.join(BB_BUILD_DIR, 'goma')) 27 GOMA_DIR = os.environ.get('GOMA_DIR', os.path.join(BB_BUILD_DIR, 'goma'))
28 28
29 def CommandToString(command): 29 def CommandToString(command):
30 """Returns quoted command that can be run in bash shell.""" 30 """Returns quoted command that can be run in bash shell."""
31 return ' '.join(map(pipes.quote, command)) 31 return ' '.join(map(pipes.quote, command))
32 32
33 33
34 def SpawnCmd(command, stdout=None): 34 def SpawnCmd(command, stdout=None, cwd=CHROME_SRC):
35 """Spawn a process without waiting for termination.""" 35 """Spawn a process without waiting for termination."""
36 print '>', CommandToString(command) 36 print '>', CommandToString(command)
37 sys.stdout.flush() 37 sys.stdout.flush()
38 if TESTING: 38 if TESTING:
39 class MockPopen(object): 39 class MockPopen(object):
40 @staticmethod 40 @staticmethod
41 def wait(): 41 def wait():
42 return 0 42 return 0
43 return MockPopen() 43 return MockPopen()
44 return subprocess.Popen(command, cwd=CHROME_SRC, stdout=stdout) 44 return subprocess.Popen(command, cwd=cwd, stdout=stdout)
45 45
46 46
47 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, 47 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False,
48 warning_code=constants.WARNING_EXIT_CODE, stdout=None): 48 warning_code=constants.WARNING_EXIT_CODE, stdout=None,
49 cwd=CHROME_SRC):
49 """Run a command relative to the chrome source root.""" 50 """Run a command relative to the chrome source root."""
50 code = SpawnCmd(command, stdout).wait() 51 code = SpawnCmd(command, stdout, cwd).wait()
51 print '<', CommandToString(command) 52 print '<', CommandToString(command)
52 if code != 0: 53 if code != 0:
53 print 'ERROR: process exited with code %d' % code 54 print 'ERROR: process exited with code %d' % code
54 if code != warning_code and flunk_on_failure: 55 if code != warning_code and flunk_on_failure:
55 bb_annotations.PrintError() 56 bb_annotations.PrintError()
56 else: 57 else:
57 bb_annotations.PrintWarning() 58 bb_annotations.PrintWarning()
58 # Allow steps to have both halting (i.e. 1) and non-halting exit codes. 59 # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
59 if code != warning_code and halt_on_failure: 60 if code != warning_code and halt_on_failure:
60 print 'FATAL %d != %d' % (code, warning_code) 61 print 'FATAL %d != %d' % (code, warning_code)
(...skipping 21 matching lines...) Expand all
82 83
83 def RunSteps(steps, step_cmds, options): 84 def RunSteps(steps, step_cmds, options):
84 unknown_steps = set(steps) - set(step for step, _ in step_cmds) 85 unknown_steps = set(steps) - set(step for step, _ in step_cmds)
85 if unknown_steps: 86 if unknown_steps:
86 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps) 87 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps)
87 sys.exit(1) 88 sys.exit(1)
88 89
89 for step, cmd in step_cmds: 90 for step, cmd in step_cmds:
90 if step in steps: 91 if step in steps:
91 cmd(options) 92 cmd(options)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698