Bug 815487 - Detect missing xpcshell.ini from mach; r=ted
authorGregory Szorc <gps@mozilla.com>
Wed, 28 Nov 2012 12:19:32 -0800
changeset 114404 a43fd511c3081e9d7c19f79e1da1fcacf91b2964
parent 114403 cd7c2afe0cb843f5ab1d11daf745ddf355814e9a
child 114405 976c19959c0587193843e7487cc8deee9e780b55
push id23917
push useremorley@mozilla.com
push dateThu, 29 Nov 2012 14:20:29 +0000
treeherdermozilla-central@c72d38e7a212 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs815487
milestone20.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 815487 - Detect missing xpcshell.ini from mach; r=ted DONTBUILD (NPOTB)
testing/xpcshell/mach_commands.py
--- a/testing/xpcshell/mach_commands.py
+++ b/testing/xpcshell/mach_commands.py
@@ -24,16 +24,22 @@ from mach.decorators import (
 
 
 if sys.version_info[0] < 3:
     unicode_type = unicode
 else:
     unicode_type = str
 
 
+# This should probably be consolidated with similar classes in other test
+# runners.
+class InvalidTestPathError(Exception):
+    """Exception raised when the test path is not valid."""
+
+
 class XPCShellRunner(MozbuildObject):
     """Run xpcshell tests."""
     def run_suite(self, **kwargs):
         manifest = os.path.join(self.topobjdir, '_tests', 'xpcshell',
             'xpcshell.ini')
 
         self._run_xpcshell_harness(manifest=manifest, **kwargs)
 
@@ -53,16 +59,24 @@ class XPCShellRunner(MozbuildObject):
         relative_dir = test_file
 
         if test_file.startswith(self.topsrcdir):
             relative_dir = test_file[len(self.topsrcdir):]
 
         test_dir = os.path.join(self.topobjdir, '_tests', 'xpcshell',
                 os.path.dirname(relative_dir))
 
+        xpcshell_ini_file = os.path.join(test_dir, 'xpcshell.ini')
+        if not os.path.exists(xpcshell_ini_file):
+            raise InvalidTestPathError('An xpcshell.ini could not be found '
+                'for the passed test path. Please select a path whose '
+                'directory contains an xpcshell.ini file. It is possible you '
+                'received this error because the tree is not built or tests '
+                'are not enabled.')
+
         args = {
             'debug': debug,
             'interactive': interactive,
             'keep_going': keep_going,
             'shuffle': shuffle,
             'test_dirs': [test_dir],
         }
 
@@ -148,10 +162,15 @@ class MachCommands(MachCommandBase):
         help='Randomize the execution order of tests.')
     def run_xpcshell_test(self, **params):
         # We should probably have a utility function to ensure the tree is
         # ready to run tests. Until then, we just create the state dir (in
         # case the tree wasn't built with mach).
         self._ensure_state_subdir_exists('.')
 
         xpcshell = self._spawn(XPCShellRunner)
-        xpcshell.run_test(**params)
 
+        try:
+            return xpcshell.run_test(**params)
+        except InvalidTestPathError as e:
+            print(e.message)
+            return 1
+