[Android] Refactor so that few pieces can be reused downstream.
BUG=249997 NOTRY=True Review URL: https://chromiumcodereview.appspot.com/18325030 git-svn-id: http://src.chromium.org/svn/trunk/src/build@211209 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
145a27fabe
Коммит
83a253d9aa
|
@ -213,29 +213,20 @@ def GetRunBotOptParser():
|
|||
return parser
|
||||
|
||||
|
||||
def main(argv):
|
||||
parser = GetRunBotOptParser()
|
||||
options, args = parser.parse_args(argv[1:])
|
||||
if args:
|
||||
parser.error('Unused args: %s' % args)
|
||||
|
||||
def GetBotConfig(options, bot_step_map):
|
||||
bot_id = options.bot_id or options.factory_properties.get('android_bot_id')
|
||||
if not bot_id:
|
||||
parser.error('A bot id must be specified through option or factory_props.')
|
||||
print (sys.stderr,
|
||||
'A bot id must be specified through option or factory_props.')
|
||||
return
|
||||
|
||||
bot_config = GetBestMatch(GetBotStepMap(), bot_id)
|
||||
bot_config = GetBestMatch(bot_step_map, bot_id)
|
||||
if not bot_config:
|
||||
print 'Error: config for id="%s" cannot be inferred.' % bot_id
|
||||
return 1
|
||||
return bot_config
|
||||
|
||||
print 'Using config:', bot_config
|
||||
|
||||
commands = GetCommands(options, bot_config)
|
||||
for command in commands:
|
||||
print 'Will run: ', bb_utils.CommandToString(command)
|
||||
print
|
||||
|
||||
env = GetEnvironment(bot_config.host_obj, options.testing)
|
||||
def RunBotCommands(options, commands, env):
|
||||
print 'Environment changes:'
|
||||
print DictDiff(dict(os.environ), env)
|
||||
|
||||
|
@ -249,5 +240,26 @@ def main(argv):
|
|||
return return_code
|
||||
|
||||
|
||||
def main(argv):
|
||||
parser = GetRunBotOptParser()
|
||||
options, args = parser.parse_args(argv[1:])
|
||||
if args:
|
||||
parser.error('Unused args: %s' % args)
|
||||
|
||||
bot_config = GetBotConfig(options, GetBotStepMap())
|
||||
if not bot_config:
|
||||
sys.exit(1)
|
||||
|
||||
print 'Using config:', bot_config
|
||||
|
||||
commands = GetCommands(options, bot_config)
|
||||
for command in commands:
|
||||
print 'Will run: ', bb_utils.CommandToString(command)
|
||||
print
|
||||
|
||||
env = GetEnvironment(bot_config.host_obj, options.testing)
|
||||
return RunBotCommands(options, commands, env)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
|
|
@ -11,14 +11,13 @@ BUILDBOT_DIR = os.path.join(os.path.dirname(__file__), '..')
|
|||
sys.path.append(BUILDBOT_DIR)
|
||||
import bb_run_bot
|
||||
|
||||
|
||||
def main():
|
||||
def RunBotsWithTesting(bot_step_map):
|
||||
code = 0
|
||||
procs = [
|
||||
(bot, subprocess.Popen(
|
||||
[os.path.join(BUILDBOT_DIR, 'bb_run_bot.py'), '--bot-id', bot,
|
||||
'--testing'], stdout=subprocess.PIPE, stderr=subprocess.PIPE))
|
||||
for bot in bb_run_bot.GetBotStepMap()]
|
||||
for bot in bot_step_map]
|
||||
for bot, proc in procs:
|
||||
_, err = proc.communicate()
|
||||
code |= proc.returncode
|
||||
|
@ -28,5 +27,9 @@ def main():
|
|||
return code
|
||||
|
||||
|
||||
def main():
|
||||
return RunBotsWithTesting(bb_run_bot.GetBotStepMap())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
|
Загрузка…
Ссылка в новой задаче