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

Unified Diff: build/android/buildbot/bb_run_bot.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: Change title so that all refactors are captured in one CL Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: build/android/buildbot/bb_run_bot.py
diff --git a/build/android/buildbot/bb_run_bot.py b/build/android/buildbot/bb_run_bot.py
index 89b272f7c3836f54638072b74cec02598fe9db80..6953b2849f4bfb209ffc2d1d37cffe9634d7c9c5 100755
--- a/build/android/buildbot/bb_run_bot.py
+++ b/build/android/buildbot/bb_run_bot.py
@@ -25,6 +25,17 @@ HostConfig = collections.namedtuple(
TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args'])
+def CreateBotConfig(bot_id, host_object, test_object=None):
Isaac (away) 2013/06/28 01:39:12 Just call these BotConfig, HostConfig and TestConf
Siva Chandra 2013/06/28 21:34:10 Done.
+ return BotConfig(bot_id, host_object, test_object)
+
+def CreateTestConfig(tests, extra_args=None):
+ return TestConfig(tests, extra_args)
+
+def CreateHostConfig(host_steps, extra_args=None, extra_gyp=None,
+ target_arch=None):
+ return HostConfig(host_steps, extra_args, extra_gyp, target_arch)
+
+
def DictDiff(d1, d2):
diff = []
for key in sorted(set(d1.keys() + d2.keys())):
@@ -74,24 +85,25 @@ def GetEnvironment(host_obj, testing):
return env
-def GetCommands(options, bot_config):
+def GetCommands(options, bot_config, host_step_script, device_step_script):
Isaac (away) 2013/06/28 01:39:12 These args are fragile, I'd prefer overrides to th
Siva Chandra 2013/06/28 21:34:10 Done.
"""Get a formatted list of commands.
Args:
options: Options object.
bot_config: A BotConfig named tuple.
+ host_step_script: Host step script.
+ device_step_script: Device step script.
Returns:
list of Command objects.
"""
property_args = bb_utils.EncodeProperties(options)
- commands = [['build/android/buildbot/bb_host_steps.py'] +
- ['--steps=%s' % ','.join(bot_config.host_obj.host_steps)] +
+ commands = [[host_step_script,
+ '--steps=%s' % ','.join(bot_config.host_obj.host_steps)] +
property_args + (bot_config.host_obj.extra_args or [])]
test_obj = bot_config.test_obj
if test_obj:
- run_test_cmd = [
- 'build/android/buildbot/bb_device_steps.py', '--reboot'] + property_args
+ run_test_cmd = [device_step_script, '--reboot'] + property_args
for test in test_obj.tests:
run_test_cmd.extend(['-f', test])
if test_obj.extra_args:
@@ -108,14 +120,9 @@ def GetBotStepMap():
std_tests = ['ui', 'unit']
flakiness_server = '--upload-to-flakiness-server'
- def B(bot_id, host_object, test_object=None):
- return BotConfig(bot_id, host_object, test_object)
-
- def T(tests, extra_args=None):
- return TestConfig(tests, extra_args)
-
- def H(host_steps, extra_args=None, extra_gyp=None, target_arch=None):
- return HostConfig(host_steps, extra_args, extra_gyp, target_arch)
+ B = CreateBotConfig
+ H = CreateHostConfig
+ T = CreateTestConfig
bot_configs = [
# Main builders
@@ -180,11 +187,28 @@ def GetBotStepMap():
return bot_map
-def main(argv):
+def GetBotConfig(bot_step_map, bot_id):
Isaac (away) 2013/06/28 01:39:12 Please name this something more generic, such as '
Siva Chandra 2013/06/28 21:34:10 Done.
+ bot_config = bot_step_map.get(bot_id)
+ if not bot_config:
+ substring_matches = filter(lambda x: x in bot_id, bot_step_map.iterkeys())
+ if substring_matches:
+ max_id = max(substring_matches, key=len)
+ print 'Using config from id="%s" (substring match).' % max_id
+ bot_config = bot_step_map[max_id]
+ return bot_config
+
+
+def GetRunBotOptParser():
parser = bb_utils.GetParser()
parser.add_option('--bot-id', help='Specify bot id directly.')
parser.add_option('--testing', action='store_true',
help='For testing: print, but do not run commands')
+
+ return parser
+
+
+def main(argv):
+ parser = GetRunBotOptParser()
options, args = parser.parse_args(argv[1:])
if args:
parser.error('Unused args: %s' % args)
@@ -197,21 +221,17 @@ def main(argv):
# match, look for a bot-id which is a substring of the specified id.
# This allows similar bots to have unique IDs, but to share config.
# If multiple substring matches exist, pick the longest one.
- bot_map = GetBotStepMap()
- bot_config = bot_map.get(bot_id)
- if not bot_config:
- substring_matches = filter(lambda x: x in bot_id, bot_map.iterkeys())
- if substring_matches:
- max_id = max(substring_matches, key=len)
- print 'Using config from id="%s" (substring match).' % max_id
- bot_config = bot_map[max_id]
+ bot_config = GetBotConfig(GetBotStepMap(), bot_id)
if not bot_config:
print 'Error: config for id="%s" cannot be inferred.' % bot_id
return 1
print 'Using config:', bot_config
- commands = GetCommands(options, bot_config)
+ commands = GetCommands(
+ options, bot_config,
+ 'build/android/buildbot/bb_host_steps.py',
+ 'build/android/buildbot/bb_device_steps.py')
for command in commands:
print 'Will run: ', bb_utils.CommandToString(command)
print

Powered by Google App Engine
This is Rietveld 408576698