--- a/tools/tryselect/selectors/syntax.py
+++ b/tools/tryselect/selectors/syntax.py
@@ -1,14 +1,13 @@
# 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/.
import argparse
-import itertools
import os
import re
import subprocess
import sys
import which
from collections import defaultdict
@@ -16,44 +15,48 @@ import ConfigParser
def arg_parser():
parser = argparse.ArgumentParser()
parser.add_argument('paths', nargs='*', help='Paths to search for tests to run on try.')
parser.add_argument('-b', '--build', dest='builds', default='do',
help='Build types to run (d for debug, o for optimized).')
parser.add_argument('-p', '--platform', dest='platforms', action='append',
- help='Platforms to run (required if not found in the environment as AUTOTRY_PLATFORM_HINT).')
+ help='Platforms to run (required if not found in the environment as '
+ 'AUTOTRY_PLATFORM_HINT).')
parser.add_argument('-u', '--unittests', dest='tests', action='append',
help='Test suites to run in their entirety.')
parser.add_argument('-t', '--talos', dest='talos', action='append',
help='Talos suites to run.')
parser.add_argument('-j', '--jobs', dest='jobs', action='append',
help='Job tasks to run.')
parser.add_argument('--tag', dest='tags', action='append',
help='Restrict tests to the given tag (may be specified multiple times).')
parser.add_argument('--and', action='store_true', dest='intersection',
- help='When -u and paths are supplied run only the intersection of the tests specified by the two arguments.')
+ help='When -u and paths are supplied run only the intersection of the '
+ 'tests specified by the two arguments.')
parser.add_argument('--no-push', dest='push', action='store_false',
help='Do not push to try as a result of running this command (if '
'specified this command will only print calculated try '
'syntax and selection info).')
parser.add_argument('--save', dest='save', action='store',
help='Save the command line arguments for future use with --preset.')
parser.add_argument('--preset', dest='load', action='store',
- help='Load a saved set of arguments. Additional arguments will override saved ones.')
+ help='Load a saved set of arguments. Additional arguments will override '
+ 'saved ones.')
parser.add_argument('--list', action='store_true',
help='List all saved try strings')
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False,
help='Print detailed information about the resulting test selection '
'and commands performed.')
for arg, opts in AutoTry.pass_through_arguments.items():
parser.add_argument(arg, **opts)
return parser
+
class TryArgumentTokenizer(object):
symbols = [("seperator", ","),
("list_start", "\["),
("list_end", "\]"),
("item", "([^,\[\]\s][^,\[\]]+)"),
("space", "\s+")]
token_re = re.compile("|".join("(?P<%s>%s)" % item for item in symbols))
@@ -61,16 +64,17 @@ class TryArgumentTokenizer(object):
for match in self.token_re.finditer(data):
symbol = match.lastgroup
data = match.group(symbol)
if symbol == "space":
pass
else:
yield symbol, data
+
class TryArgumentParser(object):
"""Simple three-state parser for handling expressions
of the from "foo[sub item, another], bar,baz". This takes
input from the TryArgumentTokenizer and runs through a small
state machine, returning a dictionary of {top-level-item:[sub_items]}
i.e. the above would result in
{"foo":["sub item", "another"], "bar": [], "baz": []}
In the case of invalid input a ValueError is raised."""
@@ -136,21 +140,23 @@ class TryArgumentParser(object):
else:
raise ValueError
def after_list_end_state(self):
self.expect("seperator")
self.consume()
self.state = self.item_state
+
def parse_arg(arg):
tokenizer = TryArgumentTokenizer()
parser = TryArgumentParser()
return parser.parse(tokenizer.tokenize(arg))
+
class AutoTry(object):
# Maps from flavors to the job names needed to run that flavour
flavor_jobs = {
'mochitest': ['mochitest-1', 'mochitest-e10s-1'],
'xpcshell': ['xpcshell'],
'chrome': ['mochitest-o'],
'browser-chrome': ['mochitest-browser-chrome-1',
@@ -436,22 +442,22 @@ class AutoTry(object):
}
print(message.format(**string_format))
del suites['all']
suites.update({suite_name: None for suite_name in non_compiled_suites})
if suites:
parts.append("-u")
parts.append(",".join("%s%s" % (k, "[%s]" % ",".join(v) if v else "")
- for k,v in sorted(suites.items())))
+ for k, v in sorted(suites.items())))
if talos:
parts.append("-t")
parts.append(",".join("%s%s" % (k, "[%s]" % ",".join(v) if v else "")
- for k,v in sorted(talos.items())))
+ for k, v in sorted(talos.items())))
if jobs:
parts.append("-j")
parts.append(",".join(jobs))
if tags:
parts.append(' '.join('--tag %s' % t for t in tags))