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

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

Issue 17114007: [Android] Refactor the buildbot scripts to prepare for downstream usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address second round of comments Created 7 years, 5 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 | « build/android/buildbot/bb_run_bot.py ('k') | 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 11 matching lines...) Expand all
22 CHROME_SRC = os.path.abspath( 22 CHROME_SRC = os.path.abspath(
23 os.path.join(os.path.dirname(__file__), '..', '..', '..')) 23 os.path.join(os.path.dirname(__file__), '..', '..', '..'))
24 24
25 GOMA_DIR = os.environ.get('GOMA_DIR', os.path.join(BB_BUILD_DIR, 'goma')) 25 GOMA_DIR = os.environ.get('GOMA_DIR', os.path.join(BB_BUILD_DIR, 'goma'))
26 26
27 def CommandToString(command): 27 def CommandToString(command):
28 """Returns quoted command that can be run in bash shell.""" 28 """Returns quoted command that can be run in bash shell."""
29 return ' '.join(map(pipes.quote, command)) 29 return ' '.join(map(pipes.quote, command))
30 30
31 31
32 def SpawnCmd(command): 32 def SpawnCmd(command, stdout=None):
33 """Spawn a process without waiting for termination.""" 33 """Spawn a process without waiting for termination."""
34 print '>', CommandToString(command) 34 print '>', CommandToString(command)
35 sys.stdout.flush() 35 sys.stdout.flush()
36 if TESTING: 36 if TESTING:
37 class MockPopen(object): 37 class MockPopen(object):
38 @staticmethod 38 @staticmethod
39 def wait(): 39 def wait():
40 return 0 40 return 0
41 return MockPopen() 41 return MockPopen()
42 return subprocess.Popen(command, cwd=CHROME_SRC) 42 return subprocess.Popen(command, cwd=CHROME_SRC, stdout=stdout)
43 43
44 44
45 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, 45 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False,
46 warning_code=88): 46 warning_code=88, stdout=None):
47 """Run a command relative to the chrome source root.""" 47 """Run a command relative to the chrome source root."""
48 code = SpawnCmd(command).wait() 48 code = SpawnCmd(command, stdout).wait()
49 print '<', CommandToString(command) 49 print '<', CommandToString(command)
50 if code != 0: 50 if code != 0:
51 print 'ERROR: process exited with code %d' % code 51 print 'ERROR: process exited with code %d' % code
52 if code != warning_code and flunk_on_failure: 52 if code != warning_code and flunk_on_failure:
53 buildbot_report.PrintError() 53 buildbot_report.PrintError()
54 else: 54 else:
55 buildbot_report.PrintWarning() 55 buildbot_report.PrintWarning()
56 # Allow steps to have both halting (i.e. 1) and non-halting exit codes. 56 # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
57 if code != warning_code and halt_on_failure: 57 if code != warning_code and halt_on_failure:
58 print 'FATAL %d != %d' % (code, warning_code) 58 print 'FATAL %d != %d' % (code, warning_code)
(...skipping 12 matching lines...) Expand all
71 callback=ConvertJson, type='string', default={}, 71 callback=ConvertJson, type='string', default={},
72 help='factory properties in JSON format') 72 help='factory properties in JSON format')
73 return parser 73 return parser
74 74
75 75
76 def EncodeProperties(options): 76 def EncodeProperties(options):
77 return ['--factory-properties=%s' % json.dumps(options.factory_properties), 77 return ['--factory-properties=%s' % json.dumps(options.factory_properties),
78 '--build-properties=%s' % json.dumps(options.build_properties)] 78 '--build-properties=%s' % json.dumps(options.build_properties)]
79 79
80 80
81 def RunSteps(all_steps, options): 81 def RunSteps(steps, step_cmds, options):
82 if not options.steps: 82 unknown_steps = set(steps) - set(step for step, _ in step_cmds)
83 return
84
85 steps = options.steps.split(',')
86 unknown_steps = set(steps) - set(step for step, _ in all_steps)
87 if unknown_steps: 83 if unknown_steps:
88 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps) 84 print >> sys.stderr, 'FATAL: Unknown steps %s' % list(unknown_steps)
89 sys.exit(1) 85 sys.exit(1)
90 86
91 for step, cmd in all_steps: 87 for step, cmd in step_cmds:
92 if step in steps: 88 if step in steps:
93 cmd(options) 89 cmd(options)
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_run_bot.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698