Bug 1410969 - Return dict from find_paths_and_tags(); r?ahal draft
authorGregory Szorc <gps@mozilla.com>
Mon, 23 Oct 2017 10:36:38 -0700
changeset 684921 1edea624eadd5fdd8f3866bb7c5880b0344d344a
parent 684913 896f1466103b5ab9594f88a995216833ed5d1d4d
child 684922 4c365543dfc69f2c24cd7762c0299d4b2dd2b890
child 685485 3a633548ece958a0265ed8ee0b6d7ce9633d023b
push id85764
push usergszorc@mozilla.com
push dateMon, 23 Oct 2017 18:55:15 +0000
reviewersahal
bugs1410969
milestone58.0a1
Bug 1410969 - Return dict from find_paths_and_tags(); r?ahal This will make the return value more easily extensible and will help consumers know what the data structures represent. MozReview-Commit-ID: DaeYsqfMW37
testing/mach_commands.py
tools/tryselect/selectors/syntax.py
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -251,25 +251,24 @@ class Test(MachCommandBase):
             run_tests.extend(tests)
 
             if not tests:
                 print('UNKNOWN TEST: %s' % entry, file=sys.stderr)
 
         if not what:
             from tryselect.selectors.syntax import AutoTry
             at = AutoTry(self.topsrcdir, resolver, self._mach_context)
-            changed_files, changed_tags = at.find_paths_and_tags(
-                False, detect_paths=True)
-            if changed_files:
+            res = at.find_paths_and_tags(False, detect_paths=True)
+            if res['paths']:
                 print("Tests will be run based on modifications to the "
-                      "following files:\n\t%s" % "\n\t".join(changed_files))
+                      "following files:\n\t%s" % "\n\t".join(res['paths']))
 
             # TODO this code is redundant with what `find_paths_and_tags` does.
             reader = self.mozbuild_reader(config_mode='empty')
-            files_info = reader.files_info(changed_files)
+            files_info = reader.files_info(res['paths'])
 
             paths, tags, flavors = set(), set(), set()
             for info in files_info.values():
                 paths |= info.test_files
                 tags |= info.test_tags
                 flavors |= info.test_flavors
 
             # This requires multiple calls to resolve_tests, because the test
--- a/tools/tryselect/selectors/syntax.py
+++ b/tools/tryselect/selectors/syntax.py
@@ -482,17 +482,21 @@ class AutoTry(object):
 
             if verbose:
                 if paths:
                     print("Pushing tests based on the following patterns:\n\t%s" %
                           "\n\t".join(paths))
                 if tags:
                     print("Pushing tests based on the following tags:\n\t%s" %
                           "\n\t".join(tags))
-        return paths, tags
+
+        return {
+            'paths': paths,
+            'tags': tags,
+        }
 
     def normalise_list(self, items, allow_subitems=False):
         rv = defaultdict(list)
         for item in items:
             parsed = parse_arg(item)
             for key, values in parsed.iteritems():
                 rv[key].extend(values)
 
@@ -580,18 +584,20 @@ class AutoTry(object):
                 print("No saved configuration called %s found in autotry.ini" % kwargs["preset"],
                       file=sys.stderr)
 
             for key, value in kwargs.iteritems():
                 if value in (None, []) and key in defaults:
                     kwargs[key] = defaults[key]
 
         if not any(kwargs[item] for item in ("paths", "tests", "tags")):
-            kwargs["paths"], kwargs["tags"] = self.find_paths_and_tags(kwargs["verbose"],
-                                                                       kwargs["detect_paths"])
+            res = self.find_paths_and_tags(kwargs['verbose'],
+                                           kwargs['detect_paths'])
+            kwargs['paths'] = res['paths']
+            kwargs['tags'] = res['tags']
 
         builds, platforms, tests, talos, jobs, paths, tags, extra = self.validate_args(**kwargs)
 
         if paths or tags:
             paths = [os.path.relpath(os.path.normpath(os.path.abspath(item)), self.topsrcdir)
                      for item in paths]
             paths_by_flavor = self.paths_by_flavor(paths=paths, tags=tags)