#!/usr/bin/python
import argparse, sys
from valid_builders import PRETTY_NAMES, DESKTOP_PLATFORMS, DESKTOP_BUILDERS, MOBILE_BUILDERS, \
TEST_BUILDERS, TALOS_BUILDERS, TALOS_SUITES, UNITTEST_SUITES
'''Given a commit message or info file as a string of arguments
returns only those builder names that should be built
Comment has to be passed in split by whitespace, then split on :
the part before the : gets -- put in front for argparse'''
def getDesktopBuilders(platforms, builderNames, buildTypes):
desktopBuilders = []
if platforms != ['none']:
for buildType in buildTypes:
if buildType == 'opt':
buildType = 'build'
if buildType == 'debug':
buildType = 'leak test build'
for platform in platforms:
platform = 'desktop_' + platform
if platform in PRETTY_NAMES.keys():
custom_builder = "%s tryserver %s" % (PRETTY_NAMES[platform], buildType)
if custom_builder in builderNames:
desktopBuilders.extend([custom_builder])
return desktopBuilders
def getMobileBuilders(platforms, builderNames):
mobileBuilders = []
# Need the master list of all possible mobile builders for a quick 'all'
# if asking for 'all', still check against the possible builder names to make sure it exists
if platforms == ['all']:
for m in MOBILE_BUILDERS:
if m in builderNames:
mobileBuilders.extend([m])
elif platforms != ['none']:
for platform in platforms:
if platform in ('win32', 'macosx', 'linux'):
platform = 'mobile_' + platform
if platform in PRETTY_NAMES.keys():
custom_builder = "%s tryserver %s" % (PRETTY_NAMES[platform], b)
if custom_builder in builderNames:
mobileBuilders.extend([custom_builder])
return mobileBuilders
def getTestBuilders(platforms, testType, tests, builderNames, buildTypes):
testBuilders = []
# for all possible suites, add in the builderNames for that platform
if tests != ['none']:
if tests == ['all']:
if testType == "test":
tests = UNITTEST_SUITES
if testType == "talos":
tests = TALOS_SUITES
if testType == "test":
for buildType in buildTypes:
for platform in platforms:
for test in tests:
# we only do unittests on WINNT 6.1
if platform == 'win32':
custom_builder = "%s tryserver %s %s %s" % (PRETTY_NAMES[platform][1], buildType, testType, test)
else:
custom_builder = "%s tryserver %s %s %s" % (PRETTY_NAMES[platform], buildType, testType, test)
if custom_builder in (builderNames):
testBuilders.extend([custom_builder])
if testType == "talos":
for platform in platforms:
for test in tests:
if platform == 'win32':
# we still do talos runs on win2k3 ie: WINNT 5.1
for w in PRETTY_NAMES['win32']:
custom_builder = "%s tryserver %s %s" % (w, testType, test)
if custom_builder in (builderNames):
testBuilders.extend([custom_builder])
else:
custom_builder = "%s tryserver %s %s" % (PRETTY_NAMES[platform], testType, test)
if custom_builder in (builderNames):
testBuilders.extend([custom_builder])
return testBuilders
def TryParser(message, builderNames):
parser = argparse.ArgumentParser(description='Pass in a commit message and a list \
and tryParse populates the list with the builderNames\
that need schedulers.')
parser.add_argument('--build',
default='o',
dest='build',
choices='bdo',
help='accepts the build types requested ')
parser.add_argument('--p',
default='all',
dest='desktop',
help='provide a list of desktop platforms, or specify none (default is all)')
parser.add_argument('--m',
default='all',
dest='mobile',
help='provide a list of mobile platform, or specify none (default is all)')
parser.add_argument('--u',
default='none',
dest='test',
help='provide a list of unit tests, or specify all (default is None)')
parser.add_argument('--t',
default='none',
dest='talos',
help='provide a list of talos tests, or specify all (default is None)')
(args, extra) = parser.parse_known_args(message)
# Build Types input validation is covered by choices
if args.build == 'b':
args.build = ['opt', 'debug']
elif args.build == 'd':
args.build = ['debug']
elif args.build == 'o':
args.build = ['opt']
if args.desktop == 'all':
args.desktop = DESKTOP_PLATFORMS
print args.desktop
else:
args.desktop = args.desktop.split(',')
print args.desktop
if args.mobile:
args.mobile = args.mobile.split(',')
if args.test:
args.test = args.test.split(',')
if args.talos:
args.talos = args.talos.split(',')
# Get the custom builder names
customBuilderNames = getDesktopBuilders(args.desktop, builderNames, args.build)
customBuilderNames.extend(getMobileBuilders(args.mobile, builderNames))
customBuilderNames.extend(getTestBuilders(args.desktop, "test", args.test,
builderNames, args.build))
customBuilderNames.extend(getTestBuilders(args.desktop, "talos", args.talos, builderNames,
args.build))
return customBuilderNames
|