2016-05-17 01:53:22 +03:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import copy
|
2016-07-08 23:51:11 +03:00
|
|
|
import logging
|
2016-05-17 01:53:22 +03:00
|
|
|
import re
|
|
|
|
import shlex
|
|
|
|
|
2016-07-08 23:51:11 +03:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2016-05-17 01:53:22 +03:00
|
|
|
TRY_DELIMITER = 'try:'
|
|
|
|
|
|
|
|
# The build type aliases are very cryptic and only used in try flags these are
|
|
|
|
# mappings from the single char alias to a longer more recognizable form.
|
|
|
|
BUILD_TYPE_ALIASES = {
|
|
|
|
'o': 'opt',
|
|
|
|
'd': 'debug'
|
|
|
|
}
|
|
|
|
|
2016-09-12 21:41:58 +03:00
|
|
|
# consider anything in this whitelist of kinds to be governed by -b/-p
|
|
|
|
BUILD_KINDS = set([
|
2016-09-12 21:34:06 +03:00
|
|
|
'build',
|
2016-09-07 04:01:52 +03:00
|
|
|
'artifact-build',
|
2016-09-12 21:04:09 +03:00
|
|
|
'hazard',
|
2016-09-10 00:06:51 +03:00
|
|
|
'l10n',
|
2016-09-07 18:08:28 +03:00
|
|
|
'upload-symbols',
|
2016-09-07 03:48:31 +03:00
|
|
|
'valgrind',
|
2016-09-08 03:31:35 +03:00
|
|
|
'static-analysis',
|
2016-09-12 21:04:24 +03:00
|
|
|
'spidermonkey',
|
2016-09-12 21:41:58 +03:00
|
|
|
])
|
|
|
|
|
|
|
|
# anything in this list is governed by -j
|
|
|
|
JOB_KINDS = set([
|
2016-09-12 21:39:05 +03:00
|
|
|
'source-check',
|
2016-09-12 21:04:31 +03:00
|
|
|
'toolchain',
|
2016-09-08 03:32:50 +03:00
|
|
|
'marionette-harness',
|
2016-09-08 03:25:48 +03:00
|
|
|
'android-stuff',
|
2016-09-12 21:41:58 +03:00
|
|
|
])
|
|
|
|
|
2016-06-21 04:06:55 +03:00
|
|
|
|
2016-05-17 01:53:22 +03:00
|
|
|
# mapping from shortcut name (usable with -u) to a boolean function identifying
|
|
|
|
# matching test names
|
|
|
|
def alias_prefix(prefix):
|
|
|
|
return lambda name: name.startswith(prefix)
|
|
|
|
|
2016-06-21 04:06:55 +03:00
|
|
|
|
2016-05-17 01:53:22 +03:00
|
|
|
def alias_contains(infix):
|
|
|
|
return lambda name: infix in name
|
|
|
|
|
2016-06-21 04:06:55 +03:00
|
|
|
|
2016-05-17 01:53:22 +03:00
|
|
|
def alias_matches(pattern):
|
|
|
|
pattern = re.compile(pattern)
|
|
|
|
return lambda name: pattern.match(name)
|
|
|
|
|
|
|
|
UNITTEST_ALIASES = {
|
2016-06-05 00:24:59 +03:00
|
|
|
# Aliases specify shorthands that can be used in try syntax. The shorthand
|
|
|
|
# is the dictionary key, with the value representing a pattern for matching
|
|
|
|
# unittest_try_names.
|
|
|
|
#
|
|
|
|
# Note that alias expansion is performed in the absence of any chunk
|
|
|
|
# prefixes. For example, the first example above would replace "foo-7"
|
|
|
|
# with "foobar-7". Note that a few aliases allowed chunks to be specified
|
|
|
|
# without a leading `-`, for example 'mochitest-dt1'. That's no longer
|
|
|
|
# supported.
|
2016-05-17 01:53:22 +03:00
|
|
|
'cppunit': alias_prefix('cppunit'),
|
|
|
|
'crashtest': alias_prefix('crashtest'),
|
|
|
|
'crashtest-e10s': alias_prefix('crashtest-e10s'),
|
|
|
|
'e10s': alias_contains('e10s'),
|
2016-06-05 00:24:59 +03:00
|
|
|
'external-media-tests': alias_prefix('external-media-tests'),
|
2016-05-17 01:53:22 +03:00
|
|
|
'firefox-ui-functional': alias_prefix('firefox-ui-functional'),
|
|
|
|
'firefox-ui-functional-e10s': alias_prefix('firefox-ui-functional-e10s'),
|
|
|
|
'gaia-js-integration': alias_contains('gaia-js-integration'),
|
|
|
|
'gtest': alias_prefix('gtest'),
|
|
|
|
'jittest': alias_prefix('jittest'),
|
|
|
|
'jittests': alias_prefix('jittest'),
|
|
|
|
'jsreftest': alias_prefix('jsreftest'),
|
|
|
|
'jsreftest-e10s': alias_prefix('jsreftest-e10s'),
|
|
|
|
'marionette': alias_prefix('marionette'),
|
|
|
|
'marionette-e10s': alias_prefix('marionette-e10s'),
|
|
|
|
'mochitest': alias_prefix('mochitest'),
|
|
|
|
'mochitests': alias_prefix('mochitest'),
|
|
|
|
'mochitest-e10s': alias_prefix('mochitest-e10s'),
|
|
|
|
'mochitests-e10s': alias_prefix('mochitest-e10s'),
|
|
|
|
'mochitest-debug': alias_prefix('mochitest-debug-'),
|
|
|
|
'mochitest-a11y': alias_contains('mochitest-a11y'),
|
|
|
|
'mochitest-bc': alias_prefix('mochitest-browser-chrome'),
|
2016-10-05 15:57:50 +03:00
|
|
|
'mochitest-e10s-bc': alias_prefix('mochitest-e10s-browser-chrome'),
|
2016-05-17 01:53:22 +03:00
|
|
|
'mochitest-browser-chrome': alias_prefix('mochitest-browser-chrome'),
|
2016-10-05 15:57:50 +03:00
|
|
|
'mochitest-e10s-browser-chrome': alias_prefix('mochitest-e10s-browser-chrome'),
|
2016-05-17 01:53:22 +03:00
|
|
|
'mochitest-chrome': alias_contains('mochitest-chrome'),
|
|
|
|
'mochitest-dt': alias_prefix('mochitest-devtools-chrome'),
|
2016-10-05 15:57:50 +03:00
|
|
|
'mochitest-e10s-dt': alias_prefix('mochitest-e10s-devtools-chrome'),
|
2016-05-17 01:53:22 +03:00
|
|
|
'mochitest-gl': alias_prefix('mochitest-webgl'),
|
|
|
|
'mochitest-gl-e10s': alias_prefix('mochitest-webgl-e10s'),
|
2016-06-05 00:24:59 +03:00
|
|
|
'mochitest-gpu': alias_prefix('mochitest-gpu'),
|
|
|
|
'mochitest-gpu-e10s': alias_prefix('mochitest-gpu-e10s'),
|
|
|
|
'mochitest-clipboard': alias_prefix('mochitest-clipboard'),
|
|
|
|
'mochitest-clipboard-e10s': alias_prefix('mochitest-clipboard-e10s'),
|
2016-05-17 01:53:22 +03:00
|
|
|
'mochitest-jetpack': alias_prefix('mochitest-jetpack'),
|
|
|
|
'mochitest-media': alias_prefix('mochitest-media'),
|
|
|
|
'mochitest-media-e10s': alias_prefix('mochitest-media-e10s'),
|
|
|
|
'mochitest-vg': alias_prefix('mochitest-valgrind'),
|
|
|
|
'reftest': alias_matches(r'^(plain-)?reftest.*$'),
|
|
|
|
'reftest-no-accel': alias_matches(r'^(plain-)?reftest-no-accel.*$'),
|
|
|
|
'reftests': alias_matches(r'^(plain-)?reftest.*$'),
|
|
|
|
'reftests-e10s': alias_matches(r'^(plain-)?reftest-e10s.*$'),
|
|
|
|
'robocop': alias_prefix('robocop'),
|
|
|
|
'web-platform-test': alias_prefix('web-platform-tests'),
|
|
|
|
'web-platform-tests': alias_prefix('web-platform-tests'),
|
|
|
|
'web-platform-tests-e10s': alias_prefix('web-platform-tests-e10s'),
|
|
|
|
'web-platform-tests-reftests': alias_prefix('web-platform-tests-reftests'),
|
|
|
|
'web-platform-tests-reftests-e10s': alias_prefix('web-platform-tests-reftests-e10s'),
|
|
|
|
'xpcshell': alias_prefix('xpcshell'),
|
|
|
|
}
|
|
|
|
|
|
|
|
# unittest platforms can be specified by substring of the "pretty name", which
|
|
|
|
# is basically the old Buildbot builder name. This dict has {pretty name,
|
|
|
|
# [test_platforms]} translations, This includes only the most commonly-used
|
|
|
|
# substrings. This is intended only for backward-compatibility. New test
|
|
|
|
# platforms should have their `test_platform` spelled out fully in try syntax.
|
|
|
|
UNITTEST_PLATFORM_PRETTY_NAMES = {
|
2016-10-03 09:20:02 +03:00
|
|
|
'Ubuntu': ['linux', 'linux64', 'linux64-asan'],
|
2016-08-25 16:38:02 +03:00
|
|
|
'x64': ['linux64', 'linux64-asan'],
|
2016-10-02 05:19:24 +03:00
|
|
|
'Android 4.3': ['android-4.3-arm7-api-15'],
|
2016-05-17 01:53:22 +03:00
|
|
|
# other commonly-used substrings for platforms not yet supported with
|
|
|
|
# in-tree taskgraphs:
|
2016-06-21 04:06:55 +03:00
|
|
|
# '10.10': [..TODO..],
|
|
|
|
# '10.10.5': [..TODO..],
|
|
|
|
# '10.6': [..TODO..],
|
|
|
|
# '10.8': [..TODO..],
|
|
|
|
# 'Android 2.3 API9': [..TODO..],
|
|
|
|
# 'Windows 7': [..TODO..],
|
|
|
|
# 'Windows 7 VM': [..TODO..],
|
|
|
|
# 'Windows 8': [..TODO..],
|
|
|
|
# 'Windows XP': [..TODO..],
|
|
|
|
# 'win32': [..TODO..],
|
|
|
|
# 'win64': [..TODO..],
|
2016-05-17 01:53:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
# We have a few platforms for which we want to do some "extra" builds, or at
|
|
|
|
# least build-ish things. Sort of. Anyway, these other things are implemented
|
2016-09-12 21:41:58 +03:00
|
|
|
# as different "platforms". These do *not* automatically ride along with "-p
|
|
|
|
# all"
|
2016-05-17 01:53:22 +03:00
|
|
|
RIDEALONG_BUILDS = {
|
2016-09-03 17:32:22 +03:00
|
|
|
'android-api-15': [
|
|
|
|
'android-api-15-l10n',
|
|
|
|
],
|
2016-06-06 23:09:51 +03:00
|
|
|
'linux': [
|
|
|
|
'linux-l10n',
|
|
|
|
],
|
2016-05-17 01:53:22 +03:00
|
|
|
'linux64': [
|
2016-06-06 23:09:51 +03:00
|
|
|
'linux64-l10n',
|
2016-05-17 01:53:22 +03:00
|
|
|
'sm-plain',
|
2016-06-06 23:09:51 +03:00
|
|
|
'sm-nonunified',
|
2016-05-17 01:53:22 +03:00
|
|
|
'sm-arm-sim',
|
|
|
|
'sm-arm64-sim',
|
|
|
|
'sm-compacting',
|
|
|
|
'sm-rootanalysis',
|
2016-06-06 23:09:51 +03:00
|
|
|
'sm-package',
|
2016-07-08 23:51:11 +03:00
|
|
|
'sm-tsan',
|
|
|
|
'sm-asan',
|
2016-10-14 02:12:42 +03:00
|
|
|
'sm-mozjs-sys',
|
2016-07-08 23:51:11 +03:00
|
|
|
'sm-msan',
|
2016-05-17 01:53:22 +03:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CHUNK_SUFFIX = re.compile('(.*)-([0-9]+)$')
|
|
|
|
|
2016-09-26 20:57:14 +03:00
|
|
|
|
2016-05-17 01:53:22 +03:00
|
|
|
class TryOptionSyntax(object):
|
|
|
|
|
|
|
|
def __init__(self, message, full_task_graph):
|
|
|
|
"""
|
|
|
|
Parse a "try syntax" formatted commit message. This is the old "-b do -p
|
|
|
|
win32 -u all" format. Aliases are applied to map short names to full
|
|
|
|
names.
|
|
|
|
|
|
|
|
The resulting object has attributes:
|
|
|
|
|
|
|
|
- build_types: a list containing zero or more of 'opt' and 'debug'
|
|
|
|
- platforms: a list of selected platform names, or None for all
|
|
|
|
- unittests: a list of tests, of the form given below, or None for all
|
|
|
|
- jobs: a list of requested job names, or None for all
|
2016-06-21 21:50:55 +03:00
|
|
|
- trigger_tests: the number of times tests should be triggered (--rebuild)
|
2016-09-22 04:02:43 +03:00
|
|
|
- interactive: true if --interactive
|
2016-09-26 20:57:14 +03:00
|
|
|
- notifications: either None if no notifications or one of 'all' or 'failure'
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
Note that -t is currently completely ignored.
|
|
|
|
|
|
|
|
The unittests and talos lists contain dictionaries of the form:
|
|
|
|
|
|
|
|
{
|
|
|
|
'test': '<suite name>',
|
|
|
|
'platforms': [..platform names..], # to limit to only certain platforms
|
|
|
|
'only_chunks': set([..chunk numbers..]), # to limit only to certain chunks
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
self.jobs = []
|
|
|
|
self.build_types = []
|
|
|
|
self.platforms = []
|
|
|
|
self.unittests = []
|
2016-05-18 20:55:33 +03:00
|
|
|
self.talos = []
|
2016-05-17 01:53:22 +03:00
|
|
|
self.trigger_tests = 0
|
|
|
|
self.interactive = False
|
2016-09-26 20:57:14 +03:00
|
|
|
self.notifications = None
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
# shlex used to ensure we split correctly when giving values to argparse.
|
|
|
|
parts = shlex.split(self.escape_whitespace_in_brackets(message))
|
|
|
|
try_idx = None
|
|
|
|
for idx, part in enumerate(parts):
|
|
|
|
if part == TRY_DELIMITER:
|
|
|
|
try_idx = idx
|
|
|
|
break
|
|
|
|
|
|
|
|
if try_idx is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
# Argument parser based on try flag flags
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('-b', '--build', dest='build_types')
|
2016-06-21 04:06:55 +03:00
|
|
|
parser.add_argument('-p', '--platform', nargs='?',
|
|
|
|
dest='platforms', const='all', default='all')
|
|
|
|
parser.add_argument('-u', '--unittests', nargs='?',
|
|
|
|
dest='unittests', const='all', default='all')
|
2016-05-18 20:55:33 +03:00
|
|
|
parser.add_argument('-t', '--talos', nargs='?', dest='talos', const='all', default='all')
|
2016-06-21 04:06:55 +03:00
|
|
|
parser.add_argument('-i', '--interactive',
|
|
|
|
dest='interactive', action='store_true', default=False)
|
2016-09-26 20:57:14 +03:00
|
|
|
parser.add_argument('-e', '--all-emails',
|
|
|
|
dest='notifications', action='store_const', const='all')
|
|
|
|
parser.add_argument('-f', '--failure-emails',
|
|
|
|
dest='notifications', action='store_const', const='failure')
|
2016-05-17 01:53:22 +03:00
|
|
|
parser.add_argument('-j', '--job', dest='jobs', action='append')
|
|
|
|
# In order to run test jobs multiple times
|
2016-06-21 21:50:55 +03:00
|
|
|
parser.add_argument('--rebuild', dest='trigger_tests', type=int, default=1)
|
2016-05-17 01:53:22 +03:00
|
|
|
args, _ = parser.parse_known_args(parts[try_idx:])
|
|
|
|
|
|
|
|
self.jobs = self.parse_jobs(args.jobs)
|
|
|
|
self.build_types = self.parse_build_types(args.build_types)
|
|
|
|
self.platforms = self.parse_platforms(args.platforms)
|
2016-06-21 04:06:55 +03:00
|
|
|
self.unittests = self.parse_test_option(
|
|
|
|
"unittest_try_name", args.unittests, full_task_graph)
|
2016-05-18 20:55:33 +03:00
|
|
|
self.talos = self.parse_test_option("talos_try_name", args.talos, full_task_graph)
|
2016-05-17 01:53:22 +03:00
|
|
|
self.trigger_tests = args.trigger_tests
|
|
|
|
self.interactive = args.interactive
|
2016-09-26 20:57:14 +03:00
|
|
|
self.notifications = args.notifications
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
def parse_jobs(self, jobs_arg):
|
|
|
|
if not jobs_arg or jobs_arg == ['all']:
|
|
|
|
return None
|
|
|
|
expanded = []
|
|
|
|
for job in jobs_arg:
|
|
|
|
expanded.extend(j.strip() for j in job.split(','))
|
|
|
|
return expanded
|
|
|
|
|
|
|
|
def parse_build_types(self, build_types_arg):
|
|
|
|
if build_types_arg is None:
|
|
|
|
build_types_arg = []
|
2016-06-21 04:06:55 +03:00
|
|
|
build_types = filter(None, [BUILD_TYPE_ALIASES.get(build_type) for
|
|
|
|
build_type in build_types_arg])
|
2016-05-17 01:53:22 +03:00
|
|
|
return build_types
|
|
|
|
|
|
|
|
def parse_platforms(self, platform_arg):
|
|
|
|
if platform_arg == 'all':
|
|
|
|
return None
|
|
|
|
|
|
|
|
results = []
|
|
|
|
for build in platform_arg.split(','):
|
|
|
|
results.append(build)
|
|
|
|
if build in RIDEALONG_BUILDS:
|
|
|
|
results.extend(RIDEALONG_BUILDS[build])
|
2016-07-08 23:51:11 +03:00
|
|
|
logger.info("platform %s triggers ridealong builds %s" %
|
2016-09-12 21:41:58 +03:00
|
|
|
(build, ', '.join(RIDEALONG_BUILDS[build])))
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
return results
|
|
|
|
|
2016-05-18 20:55:33 +03:00
|
|
|
def parse_test_option(self, attr_name, test_arg, full_task_graph):
|
2016-05-17 01:53:22 +03:00
|
|
|
'''
|
|
|
|
|
2016-05-18 20:55:33 +03:00
|
|
|
Parse a unittest (-u) or talos (-t) option, in the context of a full
|
|
|
|
task graph containing available `unittest_try_name` or `talos_try_name`
|
|
|
|
attributes. There are three cases:
|
|
|
|
|
|
|
|
- test_arg is == 'none' (meaning an empty list)
|
|
|
|
- test_arg is == 'all' (meaning use the list of jobs for that job type)
|
|
|
|
- test_arg is comma string which needs to be parsed
|
2016-05-17 01:53:22 +03:00
|
|
|
'''
|
|
|
|
|
|
|
|
# Empty job list case...
|
2016-05-18 20:55:33 +03:00
|
|
|
if test_arg is None or test_arg == 'none':
|
2016-05-17 01:53:22 +03:00
|
|
|
return []
|
|
|
|
|
|
|
|
all_platforms = set(t.attributes['test_platform']
|
|
|
|
for t in full_task_graph.tasks.itervalues()
|
|
|
|
if 'test_platform' in t.attributes)
|
|
|
|
|
2016-05-18 20:55:33 +03:00
|
|
|
tests = self.parse_test_opts(test_arg, all_platforms)
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
if not tests:
|
|
|
|
return []
|
|
|
|
|
2016-05-18 20:55:33 +03:00
|
|
|
all_tests = set(t.attributes[attr_name]
|
2016-05-17 01:53:22 +03:00
|
|
|
for t in full_task_graph.tasks.itervalues()
|
2016-05-18 20:55:33 +03:00
|
|
|
if attr_name in t.attributes)
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
# Special case where tests is 'all' and must be expanded
|
|
|
|
if tests[0]['test'] == 'all':
|
|
|
|
results = []
|
|
|
|
all_entry = tests[0]
|
|
|
|
for test in all_tests:
|
|
|
|
entry = {'test': test}
|
|
|
|
# If there are platform restrictions copy them across the list.
|
|
|
|
if 'platforms' in all_entry:
|
|
|
|
entry['platforms'] = list(all_entry['platforms'])
|
|
|
|
results.append(entry)
|
|
|
|
return self.parse_test_chunks(all_tests, results)
|
|
|
|
else:
|
|
|
|
return self.parse_test_chunks(all_tests, tests)
|
|
|
|
|
|
|
|
def parse_test_opts(self, input_str, all_platforms):
|
|
|
|
'''
|
|
|
|
Parse `testspec,testspec,..`, where each testspec is a test name
|
|
|
|
optionally followed by a list of test platforms or negated platforms in
|
|
|
|
`[]`.
|
|
|
|
|
|
|
|
No brackets indicates that tests should run on all platforms for which
|
|
|
|
builds are available. If testspecs are provided, then each is treated,
|
|
|
|
from left to right, as an instruction to include or (if negated)
|
|
|
|
exclude a set of test platforms. A single spec may expand to multiple
|
|
|
|
test platforms via UNITTEST_PLATFORM_PRETTY_NAMES. If the first test
|
|
|
|
spec is negated, processing begins with the full set of available test
|
|
|
|
platforms; otherwise, processing begins with an empty set of test
|
|
|
|
platforms.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Final results which we will return.
|
|
|
|
tests = []
|
|
|
|
|
|
|
|
cur_test = {}
|
|
|
|
token = ''
|
|
|
|
in_platforms = False
|
|
|
|
|
|
|
|
def normalize_platforms():
|
|
|
|
if 'platforms' not in cur_test:
|
|
|
|
return
|
|
|
|
# if the first spec is a negation, start with all platforms
|
|
|
|
if cur_test['platforms'][0][0] == '-':
|
|
|
|
platforms = all_platforms.copy()
|
|
|
|
else:
|
|
|
|
platforms = []
|
|
|
|
for platform in cur_test['platforms']:
|
|
|
|
if platform[0] == '-':
|
|
|
|
platforms = [p for p in platforms if p != platform[1:]]
|
|
|
|
else:
|
|
|
|
platforms.append(platform)
|
|
|
|
cur_test['platforms'] = platforms
|
|
|
|
|
|
|
|
def add_test(value):
|
|
|
|
normalize_platforms()
|
|
|
|
cur_test['test'] = value.strip()
|
|
|
|
tests.insert(0, cur_test)
|
|
|
|
|
|
|
|
def add_platform(value):
|
|
|
|
platform = value.strip()
|
|
|
|
if platform[0] == '-':
|
|
|
|
negated = True
|
|
|
|
platform = platform[1:]
|
|
|
|
else:
|
|
|
|
negated = False
|
|
|
|
platforms = UNITTEST_PLATFORM_PRETTY_NAMES.get(platform, [platform])
|
|
|
|
if negated:
|
|
|
|
platforms = ["-" + p for p in platforms]
|
|
|
|
cur_test['platforms'] = platforms + cur_test.get('platforms', [])
|
|
|
|
|
|
|
|
# This might be somewhat confusing but we parse the string _backwards_ so
|
|
|
|
# there is no ambiguity over what state we are in.
|
|
|
|
for char in reversed(input_str):
|
|
|
|
|
|
|
|
# , indicates exiting a state
|
|
|
|
if char == ',':
|
|
|
|
|
|
|
|
# Exit a particular platform.
|
|
|
|
if in_platforms:
|
|
|
|
add_platform(token)
|
|
|
|
|
|
|
|
# Exit a particular test.
|
|
|
|
else:
|
|
|
|
add_test(token)
|
|
|
|
cur_test = {}
|
|
|
|
|
|
|
|
# Token must always be reset after we exit a state
|
|
|
|
token = ''
|
|
|
|
elif char == '[':
|
|
|
|
# Exiting platform state entering test state.
|
|
|
|
add_platform(token)
|
|
|
|
token = ''
|
|
|
|
in_platforms = False
|
|
|
|
elif char == ']':
|
|
|
|
# Entering platform state.
|
|
|
|
in_platforms = True
|
|
|
|
else:
|
|
|
|
# Accumulator.
|
|
|
|
token = char + token
|
|
|
|
|
|
|
|
# Handle any left over tokens.
|
|
|
|
if token:
|
|
|
|
add_test(token)
|
|
|
|
|
|
|
|
return tests
|
|
|
|
|
|
|
|
def handle_alias(self, test, all_tests):
|
|
|
|
'''
|
|
|
|
Expand a test if its name refers to an alias, returning a list of test
|
|
|
|
dictionaries cloned from the first (to maintain any metadata).
|
|
|
|
'''
|
|
|
|
if test['test'] not in UNITTEST_ALIASES:
|
|
|
|
return [test]
|
|
|
|
|
|
|
|
alias = UNITTEST_ALIASES[test['test']]
|
2016-06-21 04:06:55 +03:00
|
|
|
|
2016-05-17 01:53:22 +03:00
|
|
|
def mktest(name):
|
|
|
|
newtest = copy.deepcopy(test)
|
|
|
|
newtest['test'] = name
|
|
|
|
return newtest
|
|
|
|
|
|
|
|
def exprmatch(alias):
|
|
|
|
return [t for t in all_tests if alias(t)]
|
|
|
|
|
|
|
|
return [mktest(t) for t in exprmatch(alias)]
|
|
|
|
|
|
|
|
def parse_test_chunks(self, all_tests, tests):
|
|
|
|
'''
|
|
|
|
Test flags may include parameters to narrow down the number of chunks in a
|
|
|
|
given push. We don't model 1 chunk = 1 job in taskcluster so we must check
|
|
|
|
each test flag to see if it is actually specifying a chunk.
|
|
|
|
'''
|
|
|
|
results = []
|
|
|
|
seen_chunks = {}
|
|
|
|
for test in tests:
|
|
|
|
matches = TEST_CHUNK_SUFFIX.match(test['test'])
|
2016-08-16 23:56:45 +03:00
|
|
|
if matches:
|
|
|
|
name = matches.group(1)
|
|
|
|
chunk = matches.group(2)
|
2016-05-17 01:53:22 +03:00
|
|
|
if name in seen_chunks:
|
|
|
|
seen_chunks[name].add(chunk)
|
|
|
|
else:
|
|
|
|
seen_chunks[name] = {chunk}
|
|
|
|
test['test'] = name
|
|
|
|
test['only_chunks'] = seen_chunks[name]
|
|
|
|
results.append(test)
|
2016-08-16 23:56:45 +03:00
|
|
|
else:
|
|
|
|
results.extend(self.handle_alias(test, all_tests))
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
# uniquify the results over the test names
|
|
|
|
results = {test['test']: test for test in results}.values()
|
|
|
|
return results
|
|
|
|
|
|
|
|
def find_all_attribute_suffixes(self, graph, prefix):
|
|
|
|
rv = set()
|
|
|
|
for t in graph.tasks.itervalues():
|
|
|
|
for a in t.attributes:
|
|
|
|
if a.startswith(prefix):
|
|
|
|
rv.add(a[len(prefix):])
|
|
|
|
return sorted(rv)
|
|
|
|
|
|
|
|
def escape_whitespace_in_brackets(self, input_str):
|
|
|
|
'''
|
|
|
|
In tests you may restrict them by platform [] inside of the brackets
|
|
|
|
whitespace may occur this is typically invalid shell syntax so we escape it
|
|
|
|
with backslash sequences .
|
|
|
|
'''
|
|
|
|
result = ""
|
|
|
|
in_brackets = False
|
|
|
|
for char in input_str:
|
|
|
|
if char == '[':
|
|
|
|
in_brackets = True
|
|
|
|
result += char
|
|
|
|
continue
|
|
|
|
|
|
|
|
if char == ']':
|
|
|
|
in_brackets = False
|
|
|
|
result += char
|
|
|
|
continue
|
|
|
|
|
|
|
|
if char == ' ' and in_brackets:
|
|
|
|
result += '\ '
|
|
|
|
continue
|
|
|
|
|
|
|
|
result += char
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
def task_matches(self, attributes):
|
|
|
|
attr = attributes.get
|
2016-05-18 20:55:33 +03:00
|
|
|
|
2016-09-24 21:31:25 +03:00
|
|
|
def check_run_on_projects():
|
|
|
|
return set(['try', 'all']) & set(attr('run_on_projects', []))
|
|
|
|
|
2016-05-18 20:55:33 +03:00
|
|
|
def match_test(try_spec, attr_name):
|
|
|
|
if attr('build_type') not in self.build_types:
|
|
|
|
return False
|
|
|
|
if self.platforms is not None:
|
|
|
|
if attr('build_platform') not in self.platforms:
|
|
|
|
return False
|
2016-09-24 21:31:25 +03:00
|
|
|
else:
|
|
|
|
if not check_run_on_projects():
|
2016-05-18 20:55:33 +03:00
|
|
|
return False
|
2016-09-24 21:31:25 +03:00
|
|
|
if try_spec is None:
|
2016-05-18 20:55:33 +03:00
|
|
|
return True
|
2016-09-24 21:31:25 +03:00
|
|
|
# TODO: optimize this search a bit
|
|
|
|
for test in try_spec:
|
|
|
|
if attr(attr_name) == test['test']:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
if 'platforms' in test and attr('test_platform') not in test['platforms']:
|
|
|
|
return False
|
|
|
|
if 'only_chunks' in test and attr('test_chunk') not in test['only_chunks']:
|
|
|
|
return False
|
2016-05-18 20:55:33 +03:00
|
|
|
return True
|
|
|
|
|
2016-09-08 03:31:35 +03:00
|
|
|
if attr('kind') in ('desktop-test', 'android-test'):
|
Bug 1281004: Specify test tasks more flexibly; r=gps; r=gbrown
This introduces a completely new way of specifying test task in-tree,
completely replacing the old spider-web of YAML files.
The high-level view is this:
- some configuration files are used to determine which test suites to run
for each test platform, and against which build platforms
- each test suite is then represented by a dictionary, and modified by a
sequence of transforms, duplicating as necessary (e.g., chunks), until
it becomes a task definition
The transforms allow sufficient generality to support just about any desired
configuration, with the advantage that common configurations are "easy" while
unusual configurations are supported but notable for their oddness (they
require a custom transform).
As of this commit, this system produces the same set of test graphs as the
existing YAML, modulo:
- extra.treeherder.groupName -- this was not consistent in the YAML
- extra.treeherder.build -- this is ignored by taskcluster-treeherder anyway
- mozharness command argument order
- boolean True values for environment variables are now the string "true"
- metadata -- this is now much more consistent, with task name being the label
Testing of this commit demonstrates that it produces the same set of test tasks for
the following projects (those which had special cases defined in the YAML):
- autoland
- ash (*)
- willow
- mozilla-inbound
- mozilla-central
- try:
-b do -p all -t all -u all
-b d -p linux64,linux64-asan -u reftest -t none
-b d -p linux64,linux64-asan -u reftest[x64] -t none[x64]
(*) this patch omits the linux64/debug tc-M-e10s(dt) test, which is enabled on
ash; ash will require a small changeset to re-enable this test.
IGNORE BAD COMMIT MESSAGES (because the hook flags try syntax!)
MozReview-Commit-ID: G34dg9f17Hq
--HG--
rename : taskcluster/taskgraph/kind/base.py => taskcluster/taskgraph/task/base.py
rename : taskcluster/taskgraph/kind/docker_image.py => taskcluster/taskgraph/task/docker_image.py
rename : taskcluster/taskgraph/kind/legacy.py => taskcluster/taskgraph/task/legacy.py
extra : rebase_source : 03e70902c2d3a297eb9e3ce852f8737c2550d5a6
extra : histedit_source : d4d9f4b192605af21f41d83495fc3c923759c3cb
2016-07-12 02:27:14 +03:00
|
|
|
return match_test(self.unittests, 'unittest_try_name')
|
2016-09-12 21:41:58 +03:00
|
|
|
elif attr('kind') in JOB_KINDS:
|
2016-11-14 22:29:50 +03:00
|
|
|
# This will add 'job' tasks to the target set even if no try syntax was specified.
|
|
|
|
if not self.jobs:
|
2016-09-12 21:41:58 +03:00
|
|
|
return True
|
|
|
|
if attr('build_platform') in self.jobs:
|
|
|
|
return True
|
|
|
|
elif attr('kind') in BUILD_KINDS:
|
|
|
|
if attr('build_type') not in self.build_types:
|
|
|
|
return False
|
|
|
|
elif self.platforms is None:
|
|
|
|
# for "-p all", look for try in the 'run_on_projects' attribute
|
2016-09-24 21:31:25 +03:00
|
|
|
return check_run_on_projects()
|
2016-09-12 21:41:58 +03:00
|
|
|
else:
|
|
|
|
if attr('build_platform') not in self.platforms:
|
|
|
|
return False
|
|
|
|
return True
|
2016-05-17 01:53:22 +03:00
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
def none_for_all(list):
|
|
|
|
if list is None:
|
|
|
|
return '<all>'
|
2016-06-21 04:06:55 +03:00
|
|
|
return ', '.join(str(e) for e in list)
|
2016-05-17 01:53:22 +03:00
|
|
|
|
|
|
|
return "\n".join([
|
|
|
|
"build_types: " + ", ".join(self.build_types),
|
|
|
|
"platforms: " + none_for_all(self.platforms),
|
|
|
|
"unittests: " + none_for_all(self.unittests),
|
|
|
|
"jobs: " + none_for_all(self.jobs),
|
|
|
|
"trigger_tests: " + str(self.trigger_tests),
|
|
|
|
"interactive: " + str(self.interactive),
|
2016-09-22 04:02:43 +03:00
|
|
|
"notifications: " + self.notifications,
|
2016-05-17 01:53:22 +03:00
|
|
|
])
|