Bug 1126057 - Provide better error when ./mach robocop is run without MOZ_HOST_BIN. r=nalexander
authorGiovanny Andres Gongora Granada <gioyik@gmail.com>
Thu, 26 Feb 2015 10:28:00 -0800
changeset 249740 fa4247a2db1bed67ab1e3b05e5df1bef26865528
parent 249739 ddbeb492edfb88f865e8b0b89d7874bea4e082a4
child 249741 aebb5e9855dda4e3ca380102ef260c6749be03b7
push id7860
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:46:02 +0000
treeherdermozilla-aurora@8ac636cd51f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1126057
milestone39.0a1
Bug 1126057 - Provide better error when ./mach robocop is run without MOZ_HOST_BIN. r=nalexander DONTBUILD because NPOTB
testing/mochitest/mach_commands.py
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -2,16 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
 import argparse
 import logging
 import mozpack.path
+import mozpack.executables
 import os
 import sys
 import warnings
 import which
 
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
@@ -1124,19 +1125,29 @@ class AndroidCommands(MachCommandBase):
             'mochitest')
         import imp
         path = os.path.join(self.mochitest_dir, 'runtestsremote.py')
         with open(path, 'r') as fh:
             imp.load_module('runtestsremote', fh, path,
                             ('.py', 'r', imp.PY_SOURCE))
         import runtestsremote
 
+        MOZ_HOST_BIN = os.environ.get('MOZ_HOST_BIN')
+        if not MOZ_HOST_BIN:
+            print('environment variable MOZ_HOST_BIN must be set to a directory containing host xpcshell')
+            return 1
+        elif not os.path.isdir(MOZ_HOST_BIN):
+            print('$MOZ_HOST_BIN does not specify a directory')
+            return 1
+        elif not os.path.isfile(os.path.join(MOZ_HOST_BIN, 'xpcshell')):
+            print('$MOZ_HOST_BIN/xpcshell does not exist')
+            return 1
+
         args = [
-            '--xre-path=' +
-            os.environ.get('MOZ_HOST_BIN'),
+            '--xre-path=' + MOZ_HOST_BIN,
             '--dm_trans=adb',
             '--deviceIP=',
             '--console-level=INFO',
             '--app=' +
             self.substs['ANDROID_PACKAGE_NAME'],
             '--robocop-apk=' +
             os.path.join(
                 self.topobjdir,