Bug 1097125 - part 2 - make |mach reftest| and related commands support single files; r=ted.mielczarek
authorNathan Froyd <froydnj@mozilla.com>
Tue, 11 Nov 2014 12:20:33 -0500
changeset 218754 3d75b3fcfb90
parent 218753 f941c8c85ae0
child 218755 6aad17f431d1
push id27944
push usercbook@mozilla.com
push date2014-12-09 11:54 +0000
treeherdermozilla-central@acf5660d2048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1097125
milestone37.0a1
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 1097125 - part 2 - make |mach reftest| and related commands support single files; r=ted.mielczarek
layout/tools/reftest/mach_commands.py
--- a/layout/tools/reftest/mach_commands.py
+++ b/layout/tools/reftest/mach_commands.py
@@ -89,27 +89,34 @@ class ReftestRunner(MozbuildObject):
             'crashtest': 'crashtests.list',
             'crashtest-ipc': 'crashtests.list',
             'jstestbrowser': 'jstests.list'
         }
         assert suite in files
         return files[suite]
 
     def _find_manifest(self, suite, test_file):
+        """Return a tuple of (manifest-path, filter-string) for running test_file.
+
+        test_file can be a relative path to a single test file or manifest from
+        the top source directory, an absolute path to the same, or a directory
+        containing a manifest.
+        """
         assert test_file
         path_arg = self._wrap_path_argument(test_file)
         relpath = path_arg.relpath()
 
         if os.path.isdir(path_arg.srcdir_path()):
-            return mozpack.path.join(relpath, self._manifest_file(suite))
+            return (mozpack.path.join(relpath, self._manifest_file(suite)), None)
 
         if relpath.endswith('.list'):
-            return relpath
+            return (relpath, None)
 
-        raise Exception('Running a single test is not currently supported')
+        return (self._find_manifest(suite, mozpack.path.dirname(test_file))[0],
+                mozpack.path.basename(test_file))
 
     def _make_shell_string(self, s):
         return "'%s'" % re.sub("'", r"'\''", s)
 
     def run_b2g_test(self, b2g_home=None, xre_path=None, test_file=None,
                      suite=None, filter=None, **kwargs):
         """Runs a b2g reftest.
 
@@ -132,19 +139,23 @@ class ReftestRunner(MozbuildObject):
                 test_file = mozpack.path.join('layout', 'reftests')
             elif suite == 'crashtest':
                 test_file = mozpack.path.join('testing', 'crashtest')
 
         if not os.path.exists(os.path.join(self.topsrcdir, test_file)):
             test_file = mozpack.path.relpath(os.path.abspath(test_file),
                                              self.topsrcdir)
 
-        manifest = self._find_manifest(suite, test_file)
+        (manifest, single_file_filter) = self._find_manifest(suite, test_file)
         if not os.path.exists(mozpack.path.join(self.topsrcdir, manifest)):
             raise Exception('No manifest file was found at %s.' % manifest)
+        if single_file_filter:
+            if filter:
+                raise Exception('Cannot run single files in conjunction with --filter')
+            filter = single_file_filter
 
         # Need to chdir to reftest_dir otherwise imports fail below.
         os.chdir(self.reftest_dir)
 
         # The imp module can spew warnings if the modules below have
         # already been imported, ignore them.
         with warnings.catch_warnings():
             warnings.simplefilter('ignore')
@@ -244,19 +255,23 @@ class ReftestRunner(MozbuildObject):
 
         if suite not in ('reftest', 'reftest-ipc', 'crashtest', 'crashtest-ipc', 'jstestbrowser'):
             raise Exception('None or unrecognized reftest suite type.')
 
         env = {}
         extra_args = []
 
         if test_file:
-            path = self._find_manifest(suite, test_file)
+            (path, single_file_filter) = self._find_manifest(suite, test_file)
             if not os.path.exists(mozpack.path.join(self.topsrcdir, path)):
                 raise Exception('No manifest file was found at %s.' % path)
+            if single_file_filter:
+                if filter:
+                    raise Exception('Cannot run single files in conjunction with --filter')
+                filter = single_file_filter
             env[b'TEST_PATH'] = path
         if filter:
             extra_args.extend(['--filter', self._make_shell_string(filter)])
 
         pass_thru = False
 
         if debugger:
             extra_args.append('--debugger=\'%s\'' % debugger)