rename from testing/taskcluster/tests/test_commit_parser.py
rename to taskcluster/taskgraph/test/test_util_legacy_commit_parser.py
--- a/testing/taskcluster/tests/test_commit_parser.py
+++ b/taskcluster/taskgraph/test/test_util_legacy_commit_parser.py
@@ -1,19 +1,20 @@
#!/usr/bin/env python
# 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 (
+from taskgraph.util.legacy_commit_parser import (
parse_commit,
- normalize_test_list
+ normalize_test_list,
+ parse_test_opts
)
class TestCommitParser(unittest.TestCase):
def test_normalize_test_list_none(self):
self.assertEqual(
normalize_test_list({}, ['woot'], 'none'), []
)
@@ -109,17 +110,18 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/linux',
'dependents': [],
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'post-build': [],
- 'interactive': False
+ 'interactive': False,
+ 'when': {}
}
]
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'
@@ -149,17 +151,18 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/linux',
'dependents': [],
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
- 'post-build': []
+ 'post-build': [],
+ 'when': {},
}
]
result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_try_flag_in_middle_of_commit(self):
'''
@@ -190,17 +193,18 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/linux',
'dependents': [],
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
- 'post-build': []
+ 'post-build': [],
+ 'when': {}
}
]
result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_try_flags_not_specified(self):
'''
@@ -261,17 +265,18 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/linux',
'dependents': [],
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
- 'additional-parameters': {}
+ 'additional-parameters': {},
+ 'when': {}
}
]
result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_some_test_tasks_restricted(self):
'''
@@ -310,31 +315,34 @@ class TestCommitParser(unittest.TestCase
{
'task': 'task/linux-debug',
'dependents': [],
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'debug',
'interactive': False,
+ 'when': {},
},
{
'task': 'task/linux',
'dependents': [{
'allowed_build_tasks': {
'task/linux': {
- 'task':'task/web-platform-tests'
+ 'task':'task/web-platform-tests',
+ 'unittest_try_name':'web-platform-tests'
}
}
}],
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
+ 'when': {},
}
]
result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_specific_test_platforms(self):
@@ -396,60 +404,67 @@ class TestCommitParser(unittest.TestCase
{
'task': 'task/linux',
'dependents': [],
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
+ 'when': {},
},
{
'task': 'task/linux-debug',
'dependents': [],
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'debug',
'interactive': False,
+ 'when': {},
},
{
'task': 'task/win32',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/win32': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
},
{
'allowed_build_tasks': {
'task/linux-debug': {
'task': 'task/mochitest',
+ 'unittest_try_name': 'mochitest',
},
'task/win32': {
'task': 'task/mochitest',
+ 'unittest_try_name': 'mochitest',
}
}
}
],
'additional-parameters': {},
'post-build': [],
'build_name': 'win32',
'build_type': 'opt',
'interactive': False,
+ 'when': {},
}
]
result, triggers = parse_commit(commit, jobs)
- self.assertEqual(expected, result)
+ self.assertEqual(sorted(expected), sorted(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 = {
'flags': {
@@ -503,28 +518,31 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/win32',
'dependents': [
{
'allowed_build_tasks': {
'task/linux-debug': {
'task': 'task/mochitest',
+ 'unittest_try_name': 'mochitest',
},
'task/win32': {
'task': 'task/mochitest',
+ 'unittest_try_name': 'mochitest',
}
}
}
],
'additional-parameters': {},
'post-build': [],
'build_name': 'win32',
'build_type': 'opt',
'interactive': False,
+ 'when': {}
}
]
result, triggers = parse_commit(commit, jobs)
self.assertEqual(expected, result)
def test_specific_chunks(self):
'''
@@ -564,26 +582,28 @@ class TestCommitParser(unittest.TestCase
{
'task': 'task/linux',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/mochitest',
'chunks': 5,
- 'only_chunks': set([1, 2])
+ 'only_chunks': set([1, 2]),
+ 'unittest_try_name': 'mochitest',
},
}
}
],
'additional-parameters': {},
'post-build': [],
'build_name': 'linux',
'build_type': 'opt',
'interactive': False,
+ 'when': {},
}
]
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
@@ -640,91 +660,107 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/linux',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {}
},
{
'task': 'task/linux-debug',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {}
},
{
'task': 'task/linux64',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {}
},
{
'task': 'task/linux64-debug',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {}
}
]
@@ -785,113 +821,183 @@ class TestCommitParser(unittest.TestCase
expected = [
{
'task': 'task/linux',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'opt',
'post-build': [],
- 'interactive': False
+ 'interactive': False,
+ 'when': {}
},
{
'task': 'task/linux-debug',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {},
'build_name': 'linux',
'build_type': 'debug',
'post-build': [],
- 'interactive': False
+ 'interactive': False,
+ 'when': {}
},
{
'task': 'task/linux64',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {},
'build_name': 'linux64',
'build_type': 'opt',
'post-build': [],
- 'interactive': False
+ 'interactive': False,
+ 'when': {}
},
{
'task': 'task/linux64-debug',
'dependents': [
{
'allowed_build_tasks': {
'task/linux': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
},
'task/linux64-debug': {
'task': 'task/web-platform-tests',
+ 'unittest_try_name': 'web-platform-tests',
}
}
}
],
'additional-parameters': {},
'build_name': 'linux64',
'build_type': 'debug',
'post-build': [],
- 'interactive': False
+ 'interactive': False,
+ 'when': {}
}
]
result, triggers = parse_commit(commit, jobs)
- self.assertEqual(expected, result)
+ self.assertEqual(sorted(expected), sorted(result))
+
+
+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'] }]
+ )
+
+ self.assertEquals(
+ parse_test_opts('a,b, c'),
+ [
+ { 'test': 'a' },
+ { 'test': 'b' },
+ { 'test': 'c' },
+ ]
+ )
+ self.assertEquals(
+ parse_test_opts('woot, bar[b], baz, qux[ z ],a'),
+ [
+ { 'test': 'woot' },
+ { 'test': 'bar', 'platforms': ['b'] },
+ { 'test': 'baz' },
+ { 'test': 'qux', 'platforms': ['z'] },
+ { 'test': 'a' }
+ ]
+ )
+
+ self.assertEquals(
+ parse_test_opts('mochitest-3[Ubuntu,10.6,10.8,Windows XP,Windows 7,Windows 8]'),
+ [
+ {
+ 'test': 'mochitest-3',
+ 'platforms': [
+ 'Ubuntu', '10.6', '10.8', 'Windows XP', 'Windows 7', 'Windows 8'
+ ]
+ }
+ ]
+ )
+
+ self.assertEquals(
+ parse_test_opts(''),
+ []
+ )
if __name__ == '__main__':
mozunit.main()