From 894f6502ecb180e98e97a80dd3670bb0ad36e1c4 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Fri, 9 Oct 2015 10:03:48 -0400 Subject: [PATCH] Bug 1213283 - Add option to only print task names in |mach taskcluster-graph|, r=dustin --HG-- extra : commitid : B1GqUmUNAgr extra : rebase_source : 77a628083140070356e5374390d59187593ae5dc --- testing/taskcluster/mach_commands.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/testing/taskcluster/mach_commands.py b/testing/taskcluster/mach_commands.py index 7794f36afd51..f0a4b1fdadf1 100644 --- a/testing/taskcluster/mach_commands.py +++ b/testing/taskcluster/mach_commands.py @@ -6,6 +6,7 @@ from __future__ import absolute_import +from collections import defaultdict import os import json import copy @@ -288,6 +289,9 @@ class Graph(object): action="store_true", dest="interactive", help="Run the tasks with the interactive feature enabled") + @CommandArgument('--print-names-only', + action='store_true', default=False, + help="Only print the names of each scheduled task, one per line.") def create_graph(self, **params): from taskcluster_graph.commit_parser import parse_commit from slugid import nice as slugid @@ -504,6 +508,27 @@ class Graph(object): graph['scopes'] = list(set(graph['scopes'])) + if params['print_names_only']: + tIDs = defaultdict(list) + + def print_task(task, indent=0): + print('{}- {}'.format(' ' * indent, task['task']['metadata']['name'])) + + for child in tIDs[task['taskId']]: + print_task(child, indent=indent+2) + + # build a dependency map + for task in graph['tasks']: + if 'requires' in task: + for tID in task['requires']: + tIDs[tID].append(task) + + # recursively print root tasks + for task in graph['tasks']: + if 'requires' not in task: + print_task(task) + return + # When we are extending the graph remove extra fields... if params['ci'] is True: graph.pop('scopes', None)