Bug 1136028 - Escape whitespace inside of platform filters r=garndt

This commit is contained in:
jlal@mozilla.com 2015-06-08 10:57:24 -07:00
parent 1a7833a611
commit 43075a0bfc
3 changed files with 37 additions and 4 deletions

View File

@ -23,6 +23,34 @@ BUILD_TYPE_ALIASES = {
class InvalidCommitException(Exception):
pass
def escape_whitspace_in_brackets(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 normalize_platform_list(alias, all_builds, build_list):
if build_list == 'all':
return all_builds
@ -178,7 +206,7 @@ def parse_commit(message, jobs):
'''
# shlex used to ensure we split correctly when giving values to argparse.
parts = shlex.split(message)
parts = shlex.split(escape_whitspace_in_brackets(message))
try_idx = None
for idx, part in enumerate(parts):
if part == TRY_DELIMITER:

View File

@ -260,8 +260,9 @@ class TestCommitParser(unittest.TestCase):
def test_specific_test_platforms(self):
'''
This test cases covers the platform specific test exclusion options.
Intentionally includes platforms with spaces.
'''
commit = 'try: -b od -p all -u all[windows,b2g] -t none'
commit = 'try: -b od -p all -u all[Windows XP,b2g] -t none'
jobs = {
'flags': {
'builds': ['linux', 'win32'],
@ -279,7 +280,7 @@ class TestCommitParser(unittest.TestCase):
}
},
'win32': {
'platforms': ['windows'],
'platforms': ['Windows XP'],
'types': {
'opt': {
'task': 'task/win32',

View File

@ -5,6 +5,11 @@ from taskcluster_graph.try_test_parser import parse_test_opts
class TryTestParserTest(unittest.TestCase):
def test_parse_opts_valid(self):
self.assertEquals(
parse_test_opts('all[Mulet Linux]'),
[{ 'test': 'all', 'platforms': ['Mulet Linux'] }]
)
self.assertEquals(
parse_test_opts('all[Amazing, Foobar woot,yeah]'),
[{ 'test': 'all', 'platforms': ['Amazing', 'Foobar woot', 'yeah'] }]
@ -48,4 +53,3 @@ class TryTestParserTest(unittest.TestCase):
if __name__ == '__main__':
mozunit.main()