bug 1125394 - launch runtime executable stub from test app bundle on Mac; r=jmaher,marco
authorMyk Melez <myk@mozilla.org>
Wed, 06 May 2015 15:17:34 -0700
changeset 261612 9110fe02f095c924e9c1b63d58b9d914ec927b96
parent 261611 8985391fa24c4473d8328a56757a26a814d28742
child 261613 dc2fed1aa0afb9f69038daab9f161274fb09fe51
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher, marco
bugs1125394
milestone40.0a1
bug 1125394 - launch runtime executable stub from test app bundle on Mac; r=jmaher,marco
testing/mochitest/mach_commands.py
webapprt/test/chrome/TestApp.app/Contents/Info.plist
webapprt/test/chrome/TestApp.app/Contents/MacOS/webapp.ini
webapprt/test/chrome/webapprt.ini
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -3,16 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
 from argparse import Namespace
 import logging
 import mozpack.path as mozpath
 import os
+import shutil
 import sys
 import warnings
 import which
 
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
     MozbuildObject,
@@ -85,27 +86,51 @@ class MochitestRunner(MozbuildObject):
     """Easily run mochitests.
 
     This currently contains just the basics for running mochitests. We may want
     to hook up result parsing, etc.
     """
 
     def get_webapp_runtime_path(self):
         import mozinfo
-        appname = 'webapprt-stub' + mozinfo.info.get('bin_suffix', '')
+        app_name = 'webapprt-stub' + mozinfo.info.get('bin_suffix', '')
+        app_path = os.path.join(self.distdir, 'bin', app_name)
         if sys.platform.startswith('darwin'):
-            appname = os.path.join(
+            # On Mac, we copy the stub from the dist dir to the test app bundle,
+            # since we have to run it from a bundle for its windows to appear.
+            # Ideally, the build system would do this for us, and we should find
+            # a way for it to do that.
+            mac_dir_name = os.path.join(
+                self.mochitest_dir,
+                'webapprtChrome',
+                'webapprt',
+                'test',
+                'chrome',
+                'TestApp.app',
+                'Contents',
+                'MacOS')
+            mac_app_name = 'webapprt' + mozinfo.info.get('bin_suffix', '')
+            mac_app_path = os.path.join(mac_dir_name, mac_app_name)
+            shutil.copy(app_path, mac_app_path)
+            return mac_app_path
+        return app_path
+
+    # On Mac, the app invoked by runtests.py is in a different app bundle
+    # (as determined by get_webapp_runtime_path above), but the XRE path should
+    # still point to the browser's app bundle, so we set it here explicitly.
+    def get_webapp_runtime_xre_path(self):
+        if sys.platform.startswith('darwin'):
+            xre_path = os.path.join(
                 self.distdir,
                 self.substs['MOZ_MACBUNDLE_NAME'],
                 'Contents',
-                'Resources',
-                appname)
+                'Resources')
         else:
-            appname = os.path.join(self.distdir, 'bin', appname)
-        return appname
+            xre_path = os.path.join(self.distdir, 'bin')
+        return xre_path
 
     def __init__(self, *args, **kwargs):
         MozbuildObject.__init__(self, *args, **kwargs)
 
         # TODO Bug 794506 remove once mach integrates with virtualenv.
         build_path = os.path.join(self.topobjdir, 'build')
         if build_path not in sys.path:
             sys.path.append(build_path)
@@ -239,21 +264,23 @@ class MochitestRunner(MozbuildObject):
             options.immersiveMode = True
             options.browserChrome = True
         elif suite == 'a11y':
             options.a11y = True
         elif suite == 'webapprt-content':
             options.webapprtContent = True
             if not options.app or options.app == self.get_binary_path():
                 options.app = self.get_webapp_runtime_path()
+            options.xrePath = self.get_webapp_runtime_xre_path()
         elif suite == 'webapprt-chrome':
             options.webapprtChrome = True
             options.browserArgs.append("-test-mode")
             if not options.app or options.app == self.get_binary_path():
                 options.app = self.get_webapp_runtime_path()
+            options.xrePath = self.get_webapp_runtime_xre_path()
         else:
             raise Exception('None or unrecognized mochitest suite type.')
 
         if test_paths:
             resolver = self._spawn(TestResolver)
 
             tests = list(
                 resolver.resolve_tests(
new file mode 100644
--- /dev/null
+++ b/webapprt/test/chrome/TestApp.app/Contents/Info.plist
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+  <dict>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleDisplayName</key>
+    <string>TestApp</string>
+    <key>CFBundleExecutable</key>
+    <string>webapprt</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundleName</key>
+    <string>TestApp</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleVersion</key>
+    <string>0</string>
+    <key>NSHighResolutionCapable</key>
+    <true/>
+    <key>NSPrincipalClass</key>
+    <string>GeckoNSApplication</string>
+    <key>FirefoxBinary</key>
+    <string>org.mozilla.nightly</string>
+  </dict>
+</plist>
new file mode 100644
--- /dev/null
+++ b/webapprt/test/chrome/TestApp.app/Contents/MacOS/webapp.ini
@@ -0,0 +1,2 @@
+[Webapp]
+Name=TestApp
--- a/webapprt/test/chrome/webapprt.ini
+++ b/webapprt/test/chrome/webapprt.ini
@@ -44,16 +44,18 @@ support-files =
   alarm.webapp^headers^
   download.html
   download.webapp
   download.webapp^headers^
   download.test
   install-app.html
   install-app.webapp
   install-app.webapp^headers^
+  TestApp.app/Contents/Info.plist
+  TestApp.app/Contents/MacOS/webapp.ini
 
 [browser_alarm.js]
 [browser_debugger.js]
 [browser_download.js]
 [browser_geolocation-prompt-noperm.js]
 [browser_geolocation-prompt-perm.js]
 [browser_getUserMedia.js]
 [browser_install-app.js]