--- a/testing/taskcluster/taskcluster_graph/commit_parser.py
+++ b/testing/taskcluster/taskcluster_graph/commit_parser.py
@@ -15,19 +15,16 @@ TEST_CHUNK_SUFFIX = re.compile('(.*)-([0
# 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'
}
-class InvalidCommitException(Exception):
- pass
-
def escape_whitespace_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
@@ -244,18 +241,17 @@ def parse_commit(message, jobs):
parts = shlex.split(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:
- raise InvalidCommitException('Invalid commit format contain ' +
- TRY_DELIMITER)
+ return [], 0
# Argument parser based on try flag flags
parser = argparse.ArgumentParser()
parser.add_argument('-b', '--build', dest='build_types')
parser.add_argument('-p', '--platform', nargs='?', dest='platforms', const='all', default='all')
parser.add_argument('-u', '--unittests', nargs='?', dest='tests', const='all', default='all')
parser.add_argument('-i', '--interactive', dest='interactive', action='store_true', default=False)
parser.add_argument('-j', '--job', dest='jobs', action='append')
--- a/testing/taskcluster/tests/test_commit_parser.py
+++ b/testing/taskcluster/tests/test_commit_parser.py
@@ -3,18 +3,17 @@
# 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 unittest
import mozunit
from taskcluster_graph.commit_parser import (
parse_commit,
- normalize_test_list,
- InvalidCommitException
+ normalize_test_list
)
class TestCommitParser(unittest.TestCase):
def test_normalize_test_list_none(self):
self.assertEqual(
normalize_test_list({}, ['woot'], 'none'), []
)
@@ -77,23 +76,16 @@ class TestCommitParser(unittest.TestCase
self.assertEqual(sorted(
normalize_test_list({ "a": ['/.*oo/', 'bar', '/bi.*/'] },
['woot', 'foo', 'bar', 'bing', 'baz'],
'a-1, a-4, b')),
sorted([{'test': 'b'}] + [
{ 'test': t, 'only_chunks': set([1, 4])} for t in ['foo', 'bar', 'bing']])
)
- def test_invalid_commit(self):
- '''
- Disallow invalid commit messages from being parsed...
- '''
- with self.assertRaises(InvalidCommitException):
- parse_commit("wootbarbaz", {})
-
def test_commit_no_tests(self):
'''
This test covers the case of builds but no tests passed -u none
'''
commit = 'try: -b o -p linux -u none -t none'
jobs = {
'flags': {
'builds': ['linux', 'linux64'],
@@ -121,17 +113,17 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'post-build': [],
'interactive': False
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_flag_aliasing(self):
commit = 'try: -b o -p magic-alias -u none -t none'
jobs = {
'flags': {
'aliases': {
'magic-alias': 'linux'
@@ -161,17 +153,17 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
'post-build': []
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_try_flag_in_middle_of_commit(self):
'''
The try command prefix may appear anywhere this test ensures that it
works in some common cases.
'''
commit = 'Bug XXX - I like cheese try: -b o -p all -u none wootbar'
@@ -202,19 +194,49 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
'post-build': []
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
+ def test_try_flags_not_specified(self):
+ '''
+ Try flags are optional, and if not provided, should cause an empty graph
+ to be generated.
+ '''
+ commit = 'Bug XXX - test commit with no flags'
+ jobs = {
+ 'flags': {
+ 'builds': ['linux', 'linux64'],
+ 'tests': ['web-platform-tests'],
+ },
+ 'builds': {
+ 'linux': {
+ 'types': {
+ 'opt': {
+ 'task': 'task/linux',
+ },
+ 'debug': {
+ 'task': 'task/linux-debug'
+ }
+ }
+ },
+ },
+ 'tests': {}
+ }
+
+ expected = []
+
+ result, triggers = parse_commit(commit, jobs)
+ self.assertEqual(expected, result)
def test_commit_all_builds_no_tests(self):
'''
This test covers the case of all builds but no tests passed -u none
'''
commit = 'try: -b o -p all -u none -t none'
jobs = {
'flags': {
@@ -243,17 +265,17 @@ class TestCommitParser(unittest.TestCase
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
'additional-parameters': {}
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_some_test_tasks_restricted(self):
'''
This test covers the case of all builds but no tests passed -u none
'''
commit = 'try: -b do -p all -u all -t none'
jobs = {
@@ -306,19 +328,20 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
+
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 XP,b2g] -t none'
jobs = {
'flags': {
@@ -415,17 +438,17 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'post-build': [],
'build_name': 'win32',
'build_type': 'opt',
'interactive': False,
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_specific_test_platforms_with_specific_platform(self):
'''
This test cases covers the platform specific test exclusion options.
'''
commit = 'try: -b od -p win32 -u mochitest[windows] -t none'
jobs = {
@@ -495,17 +518,17 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'post-build': [],
'build_name': 'win32',
'build_type': 'opt',
'interactive': False,
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_specific_chunks(self):
'''
This test covers specifying specific chunks for a given test suite.
'''
commit = 'try: -b o -p linux -u mochitest-1,mochitest-2 -t none'
jobs = {
@@ -553,17 +576,17 @@ class TestCommitParser(unittest.TestCase
],
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_commit_with_builds_and_tests(self):
'''
This test covers the broad case of a commit which has both builds and
tests without any exclusions or other fancy logic.
'''
commit = 'try: -b od -p linux,linux64 -u web-platform-tests -t none'
@@ -700,17 +723,17 @@ class TestCommitParser(unittest.TestCase
}
}
}
],
'additional-parameters': {}
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_commit_with_builds_and_tests(self):
'''
This tests the long form of the try flags.
'''
commit = 'try: --build od --platform linux,linux64 --unittests web-platform-tests --talos none'
jobs = {
@@ -861,14 +884,14 @@ class TestCommitParser(unittest.TestCase
'additional-parameters': {},
'build_name': 'linux64',
'build_type': 'debug',
'post-build': [],
'interactive': False
}
]
- result = parse_commit(commit, jobs)
+ result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
if __name__ == '__main__':
mozunit.main()