Bug 1037858 - B2G mochitest mach command should fail early if running with PRODUCTION=1 or VARIANT=user, r=jgriffin, DONTBUILD, a=NPOTB
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 17 Jul 2014 13:38:20 -0400
changeset 194797 4f2dd4d636ac114d9e211c1779c2cecb5b59f4ae
parent 194740 be05446d4fd27a2f60d6ef071af5af88366ec26c
child 194798 286635a5a1e1d01298f1eb45380390b20ee0dcd7
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersjgriffin, DONTBUILD, NPOTB
bugs1037858
milestone33.0a1
Bug 1037858 - B2G mochitest mach command should fail early if running with PRODUCTION=1 or VARIANT=user, r=jgriffin, DONTBUILD, a=NPOTB
testing/mochitest/mach_commands.py
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -52,16 +52,26 @@ The %s command requires a non-debug gaia
 If you do not have a non-debug gaia profile, you can build one:
     $ git clone https://github.com/mozilla-b2g/gaia
     $ cd gaia
     $ make
 
 The profile should be generated in a directory called 'profile'.
 '''.lstrip()
 
+ENG_BUILD_REQUIRED = '''
+The %s command requires an engineering build. It may be the case that
+VARIANT=user or PRODUCTION=1 were set. Try re-building with VARIANT=eng:
+
+    $ VARIANT=eng ./build.sh
+
+There should be an app called 'test-container.gaiamobile.org' located in
+%s.
+'''.lstrip()
+
 # Maps test flavors to mochitest suite type.
 FLAVORS = {
     'mochitest': 'plain',
     'chrome': 'chrome',
     'browser-chrome': 'browser',
     'a11y': 'a11y',
     'webapprt-chrome': 'webapprt-chrome',
 }
@@ -152,28 +162,16 @@ class MochitestRunner(MozbuildObject):
         options.noWindow = no_window
         options.totalChunks = total_chunks
         options.thisChunk = this_chunk
 
         options.symbolsPath = os.path.join(self.distdir, 'crashreporter-symbols')
 
         options.consoleLevel = 'INFO'
         if conditions.is_b2g_desktop(self):
-
-            options.profile = options.profile or os.environ.get('GAIA_PROFILE')
-            if not options.profile:
-                print(GAIA_PROFILE_NOT_FOUND % 'mochitest-b2g-desktop')
-                return 1
-
-            if os.path.isfile(os.path.join(options.profile, 'extensions', \
-                    'httpd@gaiamobile.org')):
-                print(GAIA_PROFILE_IS_DEBUG % ('mochitest-b2g-desktop',
-                                               options.profile))
-                return 1
-
             options.desktop = True
             options.app = self.get_binary_path()
             if not options.app.endswith('-bin'):
                 options.app = '%s-bin' % options.app
             if not os.path.isfile(options.app):
                 options.app = options.app[:-len('-bin')]
 
             return mochitest.run_desktop_mochitests(parser, options)
@@ -760,24 +758,32 @@ def is_emulator(cls):
 class B2GCommands(MachCommandBase):
     """So far these are only mochitest plain. They are
     implemented separately because their command lines
     are completely different.
     """
     def __init__(self, context):
         MachCommandBase.__init__(self, context)
 
-        for attr in ('b2g_home', 'xre_path', 'device_name'):
+        for attr in ('b2g_home', 'xre_path', 'device_name', 'get_build_var'):
             setattr(self, attr, getattr(context, attr, None))
 
     @Command('mochitest-remote', category='testing',
         description='Run a remote mochitest.',
         conditions=[conditions.is_b2g, is_emulator])
     @B2GCommand
     def run_mochitest_remote(self, test_paths, **kwargs):
+        if self.get_build_var:
+            host_webapps_dir = os.path.join(self.get_build_var('TARGET_OUT_DATA'),
+                                            'local', 'webapps')
+            if not os.path.isdir(os.path.join(host_webapps_dir,
+                                              'test-container.gaiamobile.org')):
+                print(ENG_BUILD_REQUIRED % ('mochitest-remote', host_webapps_dir))
+                return 1
+
         from mozbuild.controller.building import BuildDriver
 
         if self.device_name.startswith('emulator'):
             emulator = 'arm'
             if 'x86' in self.device_name:
                 emulator = 'x86'
             kwargs['emulator'] = emulator
 
@@ -790,16 +796,27 @@ class B2GCommands(MachCommandBase):
         return mochitest.run_b2g_test(b2g_home=self.b2g_home,
                 xre_path=self.xre_path, test_paths=test_paths, **kwargs)
 
     @Command('mochitest-b2g-desktop', category='testing',
         conditions=[conditions.is_b2g_desktop],
         description='Run a b2g desktop mochitest.')
     @B2GCommand
     def run_mochitest_b2g_desktop(self, test_paths, **kwargs):
+        kwargs['profile'] = kwargs.get('profile') or os.environ.get('GAIA_PROFILE')
+        if not kwargs['profile'] or not os.path.isdir(kwargs['profile']):
+            print(GAIA_PROFILE_NOT_FOUND % 'mochitest-b2g-desktop')
+            return 1
+
+        if os.path.isfile(os.path.join(kwargs['profile'], 'extensions',
+                                       'httpd@gaiamobile.org')):
+            print(GAIA_PROFILE_IS_DEBUG % ('mochitest-b2g-desktop',
+                                           kwargs['profile']))
+            return 1
+
         from mozbuild.controller.building import BuildDriver
 
         self._ensure_state_subdir_exists('.')
 
         driver = self._spawn(BuildDriver)
         driver.install_tests(remove=False)
 
         mochitest = self._spawn(MochitestRunner)