Bug 1546757 - [tryselect] Provide defaults to generate_tasks arguments, r=Callek
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 30 Apr 2019 16:41:47 +0000
changeset 472428 d0b5adc9ff325765bfd2657625510ed26e9f2e72
parent 472427 22980cfa0285de0d9ca08eb7824bb528a8cab43c
child 472429 82b12442ef447627526f43bab6101e5047dbc07a
push id113012
push userdluca@mozilla.com
push dateFri, 03 May 2019 13:13:31 +0000
treeherdermozilla-inbound@d12dfc397c08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1546757 - [tryselect] Provide defaults to generate_tasks arguments, r=Callek This allows consumers to call 'generate_tasks()' without arguments. Differential Revision: https://phabricator.services.mozilla.com/D28770
--- a/tools/tryselect/selectors/chooser/__init__.py
+++ b/tools/tryselect/selectors/chooser/__init__.py
@@ -5,17 +5,17 @@
 from __future__ import absolute_import, print_function, unicode_literals
 import os
 import webbrowser
 from threading import Timer
 from tryselect.cli import BaseTryParser
 from tryselect.tasks import generate_tasks
-from tryselect.push import check_working_directory, push_to_try, vcs
+from tryselect.push import check_working_directory, push_to_try
 here = os.path.abspath(os.path.dirname(__file__))
 class ChooserParser(BaseTryParser):
     name = 'chooser'
     arguments = []
     common_groups = ['push', 'task']
@@ -23,17 +23,17 @@ class ChooserParser(BaseTryParser):
 def run(update=False, query=None, templates=None, full=False, parameters=None,
         save=False, preset=None, mod_presets=False, push=True, message='{msg}',
     from .app import create_application
-    tg = generate_tasks(parameters, full, root=vcs.path)
+    tg = generate_tasks(parameters, full)
     app = create_application(tg)
     if os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
         # we are in the reloader process, don't open the browser or do any try stuff
     # give app a second to start before opening the browser
--- a/tools/tryselect/selectors/coverage.py
+++ b/tools/tryselect/selectors/coverage.py
@@ -347,17 +347,17 @@ def run(templates={}, full=False, parame
     changed_sources = vcs.get_outgoing_files()
     test_files, test_chunks = find_tests(changed_sources)
     if not test_files and not test_chunks:
         print('ERROR Could not find any tests or chunks to run.')
         return 1
-    tg = generate_tasks(parameters, full, root=build.topsrcdir)
+    tg = generate_tasks(parameters, full)
     all_tasks = tg.tasks.keys()
     tasks_by_chunks = filter_tasks_by_chunks(all_tasks, test_chunks)
     tasks_by_path = filter_tasks_by_paths(all_tasks, test_files)
     tasks = filter(is_opt_task, set(tasks_by_path + tasks_by_chunks))
     if not tasks:
         print('ERROR Did not find any matching tasks after filtering.')
--- a/tools/tryselect/selectors/fuzzy.py
+++ b/tools/tryselect/selectors/fuzzy.py
@@ -11,17 +11,17 @@ import subprocess
 import sys
 from distutils.spawn import find_executable
 from mozboot.util import get_state_dir
 from mozterm import Terminal
 from ..cli import BaseTryParser
 from ..tasks import generate_tasks, filter_tasks_by_paths
-from ..push import check_working_directory, push_to_try, vcs
+from ..push import check_working_directory, push_to_try
 terminal = Terminal()
 here = os.path.abspath(os.path.dirname(__file__))
 # Some tasks show up in the target task set, but are either special cases
 # or uncommon enough that they should only be selectable with --full.
@@ -223,17 +223,17 @@ def run(update=False, query=None, inters
         test_paths=None, exact=False, closed_tree=False):
     fzf = fzf_bootstrap(update)
     if not fzf:
         return 1
-    tg = generate_tasks(parameters, full, root=vcs.path)
+    tg = generate_tasks(parameters, full)
     all_tasks = sorted(tg.tasks.keys())
     if not full:
         all_tasks = filter(filter_target_task, all_tasks)
     if test_paths:
         all_tasks = filter_tasks_by_paths(all_tasks, test_paths)
         if not all_tasks:
--- a/tools/tryselect/tasks.py
+++ b/tools/tryselect/tasks.py
@@ -48,19 +48,20 @@ def invalidate(cache, root):
     tc_dir = os.path.join(root, 'taskcluster')
     tmod = max(os.path.getmtime(os.path.join(tc_dir, p)) for p, _ in FileFinder(tc_dir))
     cmod = os.path.getmtime(cache)
     if tmod > cmod:
-def generate_tasks(params, full, root):
+def generate_tasks(params=None, full=False):
     # TODO: Remove after January 1st, 2020.
     # Try to delete the old taskgraph cache directories.
+    root = build.topsrcdir
     root_hash = hashlib.sha256(os.path.abspath(root)).hexdigest()
     old_cache_dirs = [
         os.path.join(get_state_dir(), 'cache', 'taskgraph'),
         os.path.join(get_state_dir(), 'cache', root_hash, 'taskgraph'),
     for cache_dir in old_cache_dirs:
         if os.path.isdir(cache_dir):
@@ -76,17 +77,17 @@ def generate_tasks(params, full, root):
     if not os.path.isdir(cache_dir):
     print("Task configuration changed, generating {}".format(attr.replace('_', ' ')))
     taskgraph.fast = True
     cwd = os.getcwd()
-    os.chdir(build.topsrcdir)
+    os.chdir(root)
     root = os.path.join(root, 'taskcluster', 'ci')
     params = parameters_loader(params, strict=False, overrides={'try_mode': 'try_select'})
         tg = getattr(TaskGraphGenerator(root_dir=root, parameters=params), attr)
     except ParameterMismatch as e: