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 e54fa9af69ed92a45fda0b5a3cada9599dd670b5..4f51988acd7c1bb897674c8953e21e480a8f6d62 100755 |
--- a/build/android/buildbot/bb_run_bot.py |
+++ b/build/android/buildbot/bb_run_bot.py |
@@ -15,14 +15,18 @@ import sys |
import bb_utils |
-BotConfig = collections.namedtuple( |
+_BotConfig = collections.namedtuple( |
'BotConfig', ['bot_id', 'host_obj', 'test_obj']) |
HostConfig = collections.namedtuple( |
'HostConfig', |
- ['host_steps', 'extra_args', 'extra_gyp_defines', 'target_arch']) |
+ ['script', 'host_steps', 'extra_args', 'extra_gyp_defines', 'target_arch']) |
-TestConfig = collections.namedtuple('Tests', ['tests', 'extra_args']) |
+TestConfig = collections.namedtuple('Tests', ['script', 'tests', 'extra_args']) |
+ |
+ |
+def BotConfig(bot_id, host_object, test_object=None): |
+ return _BotConfig(bot_id, host_object, test_object) |
def DictDiff(d1, d2): |
@@ -74,24 +78,25 @@ def GetEnvironment(host_obj, testing): |
return env |
-def GetCommands(options, bot_config): |
+def GetCommands(options, bot_config, host_step_script, device_step_script): |
"""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 +113,13 @@ 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 = BotConfig |
+ H = (lambda steps, extra_args=None, extra_gyp=None, target_arch=None : |
+ HostConfig('build/android/buildbot/bb_host_steps.py', steps, extra_args, |
+ extra_gyp, target_arch)) |
+ T = (lambda tests, extra_args=None : |
+ TestConfig('build/android/buildbot/bb_device_steps.py', tests, |
+ extra_args)) |
bot_configs = [ |
# Main builders |
@@ -181,11 +185,28 @@ def GetBotStepMap(): |
return bot_map |
-def main(argv): |
+def GetBestMatch(step_map, name): |
Isaac (away)
2013/06/29 09:55:39
Let's name these vars 'id_map', and 'id'
Add func
Siva Chandra
2013/07/01 23:58:53
Done.
|
+ steps = step_map.get(name) |
+ if not steps: |
Isaac (away)
2013/06/29 09:55:39
let's name this variable 'config'
Siva Chandra
2013/07/01 23:58:53
Done.
|
+ substring_matches = filter(lambda x: x in name, step_map.iterkeys()) |
+ if substring_matches: |
+ max_id = max(substring_matches, key=len) |
+ print 'Using config from id="%s" (substring match).' % max_id |
+ steps = step_map[max_id] |
+ return steps |
+ |
+ |
+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) |
@@ -198,21 +219,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 = GetBestMatch(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) |