mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 12:15:33 +00:00
56c96fa18d
We add the following command line options to Taskcluster try syntax: --spsProfile - enable profile mode. --rebuild-talos <N> - retrigger talos tests N times. --setenv <VAR>=<val> - add extra environments variables. --tag <TAG> - run tests only the tag TAG. --no-retry - doesn't retry failed jobs. We have a chicken-egg problem, as we first generate the full task graph and then parse the try message. But the graph generation step needs to know the try message to process the aforementioned options. The solution is to parse the message before graph generation and then pass the command line options to the transforms. Then, each transform can look at the option that interests it and process it accordingly. The message parse function is configured in kind.yml, which gives some flexibility for future implementations of alternative syntaxes. MozReview-Commit-ID: GPFdi0FD6Vn --HG-- extra : rebase_source : b992786158851f1099aedfce8669a163228edc51
87 lines
3.3 KiB
Python
87 lines
3.3 KiB
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/.
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
import unittest
|
|
|
|
from .. import target_tasks
|
|
from .. import try_option_syntax
|
|
from ..graph import Graph
|
|
from ..taskgraph import TaskGraph
|
|
from .util import TestTask
|
|
from mozunit import main
|
|
|
|
|
|
class FakeTryOptionSyntax(object):
|
|
|
|
def __init__(self, message, task_graph):
|
|
self.trigger_tests = 0
|
|
self.talos_trigger_tests = 0
|
|
self.notifications = None
|
|
self.env = []
|
|
self.profile = False
|
|
self.tag = None
|
|
self.no_retry = False
|
|
|
|
def task_matches(self, attributes):
|
|
return 'at-at' in attributes
|
|
|
|
|
|
class TestTargetTasks(unittest.TestCase):
|
|
|
|
def default_matches(self, run_on_projects, project):
|
|
method = target_tasks.get_method('default')
|
|
graph = TaskGraph(tasks={
|
|
'a': TestTask(kind='build', label='a',
|
|
attributes={'run_on_projects': run_on_projects}),
|
|
}, graph=Graph(nodes={'a'}, edges=set()))
|
|
parameters = {'project': project}
|
|
return 'a' in method(graph, parameters)
|
|
|
|
def test_default_all(self):
|
|
"""run_on_projects=[all] includes release, integration, and other projects"""
|
|
self.assertTrue(self.default_matches(['all'], 'mozilla-central'))
|
|
self.assertTrue(self.default_matches(['all'], 'mozilla-inbound'))
|
|
self.assertTrue(self.default_matches(['all'], 'mozilla-aurora'))
|
|
self.assertTrue(self.default_matches(['all'], 'baobab'))
|
|
|
|
def test_default_integration(self):
|
|
"""run_on_projects=[integration] includes integration projects"""
|
|
self.assertFalse(self.default_matches(['integration'], 'mozilla-central'))
|
|
self.assertTrue(self.default_matches(['integration'], 'mozilla-inbound'))
|
|
self.assertFalse(self.default_matches(['integration'], 'baobab'))
|
|
|
|
def test_default_relesae(self):
|
|
"""run_on_projects=[release] includes release projects"""
|
|
self.assertTrue(self.default_matches(['release'], 'mozilla-central'))
|
|
self.assertFalse(self.default_matches(['release'], 'mozilla-inbound'))
|
|
self.assertFalse(self.default_matches(['release'], 'baobab'))
|
|
|
|
def test_default_nothing(self):
|
|
"""run_on_projects=[] includes nothing"""
|
|
self.assertFalse(self.default_matches([], 'mozilla-central'))
|
|
self.assertFalse(self.default_matches([], 'mozilla-inbound'))
|
|
self.assertFalse(self.default_matches([], 'baobab'))
|
|
|
|
def test_try_option_syntax(self):
|
|
tasks = {
|
|
'a': TestTask(kind=None, label='a'),
|
|
'b': TestTask(kind=None, label='b', attributes={'at-at': 'yep'}),
|
|
}
|
|
graph = Graph(nodes=set('ab'), edges=set())
|
|
tg = TaskGraph(tasks, graph)
|
|
params = {'message': 'try me'}
|
|
|
|
orig_TryOptionSyntax = try_option_syntax.TryOptionSyntax
|
|
try:
|
|
try_option_syntax.TryOptionSyntax = FakeTryOptionSyntax
|
|
method = target_tasks.get_method('try_option_syntax')
|
|
self.assertEqual(method(tg, params), ['b'])
|
|
finally:
|
|
try_option_syntax.TryOptionSyntax = orig_TryOptionSyntax
|
|
|
|
if __name__ == '__main__':
|
|
main()
|