Bug 1318200 - Filter Stylo platforms when Servo isn't available; r=dustin

Stylo automation doesn't work unless Servo is present in the source
directory. This commit introduces a "check_servo" filter that prunes
tasks requiring Servo. Currently, this is implemented as a test against
platforms that are unique to Servo.

The use of relative path checking to find the topsrcdir is a bit
unfortunate. But we use this pattern elsewhere in this code.

MozReview-Commit-ID: IRtd53tudJW

--HG--
extra : rebase_source : 8c4742c13878d762fe7970eedfa5937fdaebe8c4
This commit is contained in:
Gregory Szorc 2016-11-17 17:10:01 -08:00
Родитель 0e12f1cc60
Коммит 743fc9a44c
3 изменённых файлов: 81 добавлений и 0 удалений

Просмотреть файл

@ -131,6 +131,7 @@ def get_decision_parameters(options):
# Define default filter list, as most configurations shouldn't need
# custom filters.
parameters['filters'] = [
'check_servo',
'target_tasks_method',
]

Просмотреть файл

@ -4,10 +4,16 @@
from __future__ import absolute_import, unicode_literals
import logging
import os
from . import (
target_tasks,
)
logger = logging.getLogger(__name__)
GECKO = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..'))
filter_task_functions = {}
@ -30,3 +36,24 @@ def filter_target_tasks(graph, parameters):
attr = parameters.get('target_tasks_method', 'all_tasks')
fn = target_tasks.get_method(attr)
return fn(graph, parameters)
@filter_task('check_servo')
def filter_servo(graph, parameters):
"""Filters out tasks requiring Servo if Servo isn't present."""
if os.path.exists(os.path.join(GECKO, 'servo')):
return graph.tasks.keys()
logger.info('servo/ directory not present; removing tasks requiring it')
SERVO_PLATFORMS = {
'linux64-stylo',
}
def fltr(task):
if task.attributes.get('build_platform') in SERVO_PLATFORMS:
return False
return True
return [l for l, t in graph.tasks.iteritems() if fltr(t)]

Просмотреть файл

@ -0,0 +1,53 @@
# 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, unicode_literals
import os
import shutil
import tempfile
import unittest
from mozunit import main
from .. import filter_tasks
from ..graph import (
Graph,
)
from ..taskgraph import (
TaskGraph,
)
from .util import (
TestTask,
)
class TestServoFilter(unittest.TestCase):
def setUp(self):
self._tmpdir = tempfile.mkdtemp()
filter_tasks.GECKO = self._tmpdir
def tearDown(self):
shutil.rmtree(self._tmpdir)
def test_basic(self):
graph = TaskGraph(tasks={
'a': TestTask(kind='build', label='a',
attributes={'build_platform': 'linux64'}),
'b': TestTask(kind='build', label='b',
attributes={'build_platform': 'linux64-stylo'}),
'c': TestTask(kind='desktop-test', label='c', attributes={}),
}, graph=Graph(nodes={'a', 'b', 'c'}, edges=set()))
# Missing servo/ directory should prune tasks requiring Servo.
self.assertEqual(set(filter_tasks.filter_servo(graph, {})), {'a', 'c'})
# Servo tasks should be retained if servo/ present.
os.mkdir(os.path.join(self._tmpdir, 'servo'))
self.assertEqual(set(filter_tasks.filter_servo(graph, {})),
{'a', 'b', 'c'})
if __name__ == '__main__':
main()