Bug 1286075: refactor test.py to use TransformTask; r=gps

MozReview-Commit-ID: 1H0P4mkzijG

--HG--
extra : rebase_source : 26c16cb14bb9f7bb90cbea717222f86b07af37d3
extra : source : 9930bede24bcda58c40ca0ee9085aedc00e8ec1b
This commit is contained in:
Dustin J. Mitchell 2016-07-29 22:31:22 +00:00
parent 433841b178
commit 24cb337d4d

View File

@ -9,20 +9,18 @@ import logging
import os
import yaml
from . import base
from taskgraph.util.python_path import find_object
from taskgraph.transforms.base import TransformSequence, TransformConfig
from . import transform
logger = logging.getLogger(__name__)
class TestTask(base.Task):
class TestTask(transform.TransformTask):
"""
A task implementing a Gecko test.
"""
@classmethod
def load_tasks(cls, kind, path, config, params, loaded_tasks):
def get_inputs(cls, kind, path, config, params, loaded_tasks):
# the kind on which this one depends
if len(config.get('kind-dependencies', [])) != 1:
@ -43,33 +41,18 @@ class TestTask(base.Task):
# load the test descriptions
test_descriptions = load_yaml(path, 'tests.yml')
# load the transformation functions
transforms = cls.load_transforms(config['transforms'])
# generate all tests for all test platforms
def tests():
for test_platform_name, test_platform in test_platforms.iteritems():
for test_name in test_platform['test-names']:
test = copy.deepcopy(test_descriptions[test_name])
test['build-platform'] = test_platform['build-platform']
test['test-platform'] = test_platform_name
test['build-label'] = test_platform['build-label']
test['test-name'] = test_name
yield test
for test_platform_name, test_platform in test_platforms.iteritems():
for test_name in test_platform['test-names']:
test = copy.deepcopy(test_descriptions[test_name])
test['build-platform'] = test_platform['build-platform']
test['test-platform'] = test_platform_name
test['build-label'] = test_platform['build-label']
test['test-name'] = test_name
# log each source test definition as it is created; this helps when debugging
# an exception in task generation
def log_tests(config, tests):
for test in tests:
logger.debug("Generating tasks for {} test {} on platform {}".format(
kind, test['test-name'], test['test-platform']))
kind, test_name, test['test-platform']))
yield test
transforms = TransformSequence([log_tests] + transforms)
# perform the transformations
config = TransformConfig(kind, path, config, params)
tasks = [cls(config.kind, t) for t in transforms(config, tests())]
return tasks
@classmethod
def get_builds_by_platform(cls, dep_kind, loaded_tasks):
@ -132,31 +115,6 @@ class TestTask(base.Task):
rv[test_platform]['test-names'] = test_names
return rv
@classmethod
def load_transforms(cls, transforms_cfg):
"""Load the transforms specified in kind.yml"""
transforms = []
for path in transforms_cfg:
transform = find_object(path)
transforms.append(transform)
return transforms
@classmethod
def from_json(cls, task_dict):
test_task = cls(kind=task_dict['attributes']['kind'],
task=task_dict)
return test_task
def __init__(self, kind, task):
self.dependencies = task['dependencies']
super(TestTask, self).__init__(kind, task['label'], task['attributes'], task['task'])
def get_dependencies(self, taskgraph):
return [(label, name) for name, label in self.dependencies.items()]
def optimize(self):
return False, None
def load_yaml(path, name):
"""Convenience method to load a YAML file in the kind directory"""