Пример #1
0
 def default_matches(self, attributes, parameters):
     method = target_tasks.get_method('default')
     graph = TaskGraph(tasks={
         'a':
         Task(kind='build', label='a', attributes=attributes, task={}),
     },
                       graph=Graph(nodes={'a'}, edges=set()))
     return 'a' in method(graph, parameters, {})
Пример #2
0
 def default_matches(self, run_on_projects, project):
     method = target_tasks.get_method('default')
     graph = TaskGraph(tasks={
         'a': Task(kind='build', label='a',
                   attributes={'run_on_projects': run_on_projects},
                   task={}),
     }, graph=Graph(nodes={'a'}, edges=set()))
     parameters = {'project': project}
     return 'a' in method(graph, parameters, {})
Пример #3
0
 def test_try_task_config(self):
     "try_mode = try_task_config uses the try config"
     tg = self.make_task_graph()
     method = target_tasks.get_method('try_tasks')
     params = {
         'try_mode': 'try_task_config',
         'try_task_config': {'tasks': ['a']},
     }
     self.assertEqual(method(tg, params, {}), ['a'])
Пример #4
0
 def test_try_option_syntax(self):
     "try_mode = try_option_syntax uses TryOptionSyntax"
     tg = self.make_task_graph()
     method = target_tasks.get_method("try_tasks")
     with self.fake_TryOptionSyntax():
         params = {
             "try_mode": "try_option_syntax",
             "message": "try: -p all",
         }
         self.assertEqual(method(tg, params, {}), ["b"])
Пример #5
0
 def test_try_option_syntax(self):
     "try_mode = try_option_syntax uses TryOptionSyntax"
     tg = self.make_task_graph()
     method = target_tasks.get_method('try_tasks')
     with self.fake_TryOptionSyntax():
         params = {
             'try_mode': 'try_option_syntax',
             'message': 'try: -p all',
         }
         self.assertEqual(method(tg, params, {}), ['b'])
Пример #6
0
 def test_try_option_syntax(self):
     "try_mode = try_option_syntax uses TryOptionSyntax"
     tg = self.make_task_graph()
     method = target_tasks.get_method('try_tasks')
     with self.fake_TryOptionSyntax():
         params = {
             'try_mode': 'try_option_syntax',
             'message': 'try: -p all',
         }
         self.assertEqual(method(tg, params, {}), ['b'])
Пример #7
0
 def test_try_task_config(self):
     "try_mode = try_task_config uses the try config"
     tg = self.make_task_graph()
     method = target_tasks.get_method("try_tasks")
     params = {
         "try_mode": "try_task_config",
         "try_task_config": {
             "tasks": ["a"]
         },
     }
     self.assertEqual(method(tg, params, {}), ["a"])
Пример #8
0
 def test_empty_try(self):
     "try_mode = None runs nothing"
     tg = self.make_task_graph()
     method = target_tasks.get_method("try_tasks")
     params = {
         "try_mode": None,
         "project": "try",
         "message": "",
     }
     # only runs the task with run_on_projects: try
     self.assertEqual(method(tg, params, {}), [])
Пример #9
0
 def test_try_task_config(self):
     "try_mode = try_task_config uses the try config"
     tg = self.make_task_graph()
     method = target_tasks.get_method('try_tasks')
     params = {
         'try_mode': 'try_task_config',
         'try_task_config': {
             'tasks': ['a']
         },
     }
     self.assertEqual(method(tg, params, {}), ['a'])
Пример #10
0
 def test_empty_try(self):
     "try_mode = None runs nothing"
     tg = self.make_task_graph()
     method = target_tasks.get_method('try_tasks')
     params = {
         'try_mode': None,
         'project': 'try',
         'message': '',
     }
     # only runs the task with run_on_projects: try
     self.assertEqual(method(tg, params, {}), [])
Пример #11
0
 def test_empty_try(self):
     "try_mode = None runs nothing"
     tg = self.make_task_graph()
     method = target_tasks.get_method('try_tasks')
     params = {
         'try_mode': None,
         'project': 'try',
         'message': '',
     }
     # only runs the task with run_on_projects: try
     self.assertEqual(method(tg, params, {}), [])
Пример #12
0
 def default_matches(self, attributes, parameters):
     method = target_tasks.get_method("default")
     graph = TaskGraph(
         tasks={
             "a": Task(kind="build",
                       label="a",
                       attributes=attributes,
                       task={}),
         },
         graph=Graph(nodes={"a"}, edges=set()),
     )
     return "a" in method(graph, parameters, {})
Пример #13
0
 def default_matches(self, run_on_projects, project):
     method = target_tasks.get_method('default')
     graph = TaskGraph(tasks={
         'a':
         Task(kind='build',
              label='a',
              attributes={'run_on_projects': run_on_projects},
              task={}),
     },
                       graph=Graph(nodes={'a'}, edges=set()))
     parameters = {'project': project}
     return 'a' in method(graph, parameters)
Пример #14
0
    def test_try_tasks(self):
        tasks = {
            'a': Task(kind=None, label='a', attributes={}, task={}),
            'b': Task(kind=None,
                      label='b',
                      attributes={'at-at': 'yep'},
                      task={}),
            'c': Task(kind=None, label='c', attributes={}, task={}),
        }
        graph = Graph(nodes=set('abc'), edges=set())
        tg = TaskGraph(tasks, graph)

        method = target_tasks.get_method('try_tasks')
        config = os.path.join(os.getcwd(), 'try_task_config.json')

        orig_TryOptionSyntax = try_option_syntax.TryOptionSyntax
        try:
            try_option_syntax.TryOptionSyntax = FakeTryOptionSyntax

            # no try specifier
            self.assertEqual(method(tg, {'message': ''}), ['b'])

            # try syntax only
            self.assertEqual(method(tg, {'message': 'try: me'}), ['b'])

            # try task config only
            with open(config, 'w') as fh:
                fh.write('["c"]')
            self.assertEqual(method(tg, {'message': ''}), ['c'])

            with open(config, 'w') as fh:
                fh.write('{"c": {}}')
            self.assertEqual(method(tg, {'message': ''}), ['c'])

            # both syntax and config
            self.assertEqual(set(method(tg, {'message': 'try: me'})),
                             set(['b', 'c']))
        finally:
            try_option_syntax.TryOptionSyntax = orig_TryOptionSyntax
            if os.path.isfile(config):
                os.remove(config)
Пример #15
0
    def test_try_tasks(self):
        tasks = {
            'a': Task(kind=None, label='a', attributes={}, task={}),
            'b': Task(kind=None,
                      label='b',
                      attributes={'at-at': 'yep'},
                      task={}),
            'c': Task(kind=None, label='c', attributes={}, task={}),
        }
        graph = Graph(nodes=set('abc'), edges=set())
        tg = TaskGraph(tasks, graph)

        method = target_tasks.get_method('try_tasks')
        params = {
            'message': '',
            'target_task_labels': [],
        }

        orig_TryOptionSyntax = try_option_syntax.TryOptionSyntax
        try:
            try_option_syntax.TryOptionSyntax = FakeTryOptionSyntax

            # no try specifier
            self.assertEqual(method(tg, params), ['b'])

            # try syntax only
            params['message'] = 'try: me'
            self.assertEqual(method(tg, params), ['b'])

            # try task config only
            params['message'] = ''
            params['target_task_labels'] = ['c']
            self.assertEqual(method(tg, params), ['c'])

            # both syntax and config
            params['message'] = 'try: me'
            self.assertEqual(set(method(tg, params)), set(['b', 'c']))
        finally:
            try_option_syntax.TryOptionSyntax = orig_TryOptionSyntax