Bug 1560073 - Change default android package name for most mach test commands; r=snorp,nalexander,maja_zf
authorGeoff Brown <gbrown@mozilla.com>
Wed, 26 Jun 2019 02:34:49 +0000
changeset 480122 95654f223f59b98cfecfea1744f2e0c255366b51
parent 480121 09b3d826af112c35179e87ea0ac804d787cbc2ba
child 480138 741653aeeb8eefc14d670bddb939199694a3001c
push id88517
push usergbrown@mozilla.com
push dateWed, 26 Jun 2019 02:35:27 +0000
treeherderautoland@95654f223f59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, nalexander, maja_zf
bugs1560073, 1553225
milestone69.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 1560073 - Change default android package name for most mach test commands; r=snorp,nalexander,maja_zf Use the geckoview TestRunnerActivity, org.mozilla.geckoview.test, by default for all types of mochitests, reftests, and web-platform tests. TRA is already the default for gtest and geckoview-junit. Fennec, based on ANDROID_PACKAGE_NAME, remains the default for robocop and marionette-test and I have no plans to change those. There is a related issue for xpcshell-test -- not the package name, but the default apk -- but I am reluctant to handle that until bug 1553225 is resolved. Differential Revision: https://phabricator.services.mozilla.com/D35479
layout/tools/reftest/mach_commands.py
layout/tools/reftest/mach_test_package_commands.py
testing/mochitest/mach_commands.py
testing/mochitest/mach_test_package_commands.py
testing/mochitest/mochitest_options.py
testing/mozbase/mozrunner/mozrunner/devices/android_device.py
testing/web-platform/mach_commands.py
--- a/layout/tools/reftest/mach_commands.py
+++ b/layout/tools/reftest/mach_commands.py
@@ -90,17 +90,17 @@ class ReftestRunner(MozbuildObject):
         try:
             rv = runreftest.run_test_harness(parser, args)
         finally:
             self.log_manager.disable_unstructured()
 
         return rv
 
     def run_android_test(self, **kwargs):
-        """Runs a reftest, in Firefox for Android."""
+        """Runs a reftest, in an Android application."""
 
         args = Namespace(**kwargs)
         if args.suite not in ('reftest', 'crashtest', 'jstestbrowser'):
             raise Exception('None or unrecognized reftest suite type.')
 
         self._setup_objdir(args)
         import remotereftest
 
@@ -125,17 +125,17 @@ class ReftestRunner(MozbuildObject):
 
         if not args.httpdPath:
             args.httpdPath = os.path.join(self.tests_dir, "modules")
         if not args.symbolsPath:
             args.symbolsPath = os.path.join(self.topobjdir, "crashreporter-symbols")
         if not args.xrePath:
             args.xrePath = os.environ.get("MOZ_HOST_BIN")
         if not args.app:
-            args.app = self.substs["ANDROID_PACKAGE_NAME"]
+            args.app = "org.mozilla.geckoview.test"
         if not args.utilityPath:
             args.utilityPath = args.xrePath
         args.ignoreWindowSize = True
         args.printDeviceInfo = False
 
         from mozrunner.devices.android_device import grant_runtime_permissions, get_adb_path
         grant_runtime_permissions(self, args.app, device_serial=args.deviceSerial)
 
--- a/layout/tools/reftest/mach_test_package_commands.py
+++ b/layout/tools/reftest/mach_test_package_commands.py
@@ -42,17 +42,17 @@ def run_reftest_desktop(context, args):
     args.utilityPath = context.bin_dir
 
     return run_test_harness(parser, args)
 
 
 def run_reftest_android(context, args):
     from remotereftest import run_test_harness
 
-    args.app = args.app or 'org.mozilla.fennec'
+    args.app = args.app or 'org.mozilla.geckoview.test'
     args.utilityPath = context.hostutils
     args.xrePath = context.hostutils
     args.httpdPath = context.module_dir
     args.ignoreWindowSize = True
     args.printDeviceInfo = False
 
     config = context.mozharness_config
     if config:
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -447,17 +447,17 @@ class MachCommands(MachCommandBase):
                 buildapp, '\n'.join(sorted(msg))))
             return 1
 
         if buildapp == 'android':
             from mozrunner.devices.android_device import grant_runtime_permissions
             from mozrunner.devices.android_device import verify_android_device
             app = kwargs.get('app')
             if not app:
-                app = self.substs["ANDROID_PACKAGE_NAME"]
+                app = "org.mozilla.geckoview.test"
             device_serial = kwargs.get('deviceSerial')
 
             # verify installation
             verify_android_device(self, install=True, xre=False, network=True,
                                   app=app, device_serial=device_serial)
             grant_runtime_permissions(self, app, device_serial=device_serial)
             run_mochitest = mochitest.run_android_test
         else:
@@ -561,17 +561,17 @@ class RobocopCommands(MachCommandBase):
                 sorted(list(test_paths)))))
             return 1
 
         from mozrunner.devices.android_device import grant_runtime_permissions, get_adb_path
         from mozrunner.devices.android_device import verify_android_device
         # verify installation
         app = kwargs.get('app')
         if not app:
-            app = self.substs["ANDROID_PACKAGE_NAME"]
+            kwargs['app'] = app = self.substs["ANDROID_PACKAGE_NAME"]
         device_serial = kwargs.get('deviceSerial')
         verify_android_device(self, install=True, xre=False, network=True,
                               app=app, device_serial=device_serial)
         grant_runtime_permissions(self, app, device_serial=device_serial)
 
         if not kwargs['adbPath']:
             kwargs['adbPath'] = get_adb_path(self)
 
--- a/testing/mochitest/mach_test_package_commands.py
+++ b/testing/mochitest/mach_test_package_commands.py
@@ -55,17 +55,17 @@ def run_mochitest_desktop(context, args)
     args.utilityPath = context.bin_dir
     args.extraProfileFiles.append(os.path.join(context.bin_dir, 'plugins'))
 
     from runtests import run_test_harness
     return run_test_harness(parser, args)
 
 
 def run_mochitest_android(context, args):
-    args.app = args.app or 'org.mozilla.fennec'
+    args.app = args.app or 'org.mozilla.geckoview.test'
     args.extraProfileFiles.append(os.path.join(context.package_root, 'mochitest', 'fonts'))
     args.utilityPath = context.hostutils
     args.xrePath = context.hostutils
 
     config = context.mozharness_config
     if config:
         args.remoteWebServer = config['remote_webserver']
         args.httpPort = config['emulator']['http_port']
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -940,20 +940,17 @@ class AndroidArguments(ArgumentContainer
                 options.remoteWebServer = moznetwork.get_ip()
             else:
                 parser.error(
                     "you must specify a --remote-webserver=<ip address>")
 
         options.webServer = options.remoteWebServer
 
         if options.app is None:
-            if build_obj:
-                options.app = build_obj.substs['ANDROID_PACKAGE_NAME']
-            else:
-                parser.error("You must specify either appPath or app")
+            options.app = "org.mozilla.geckoview.test"
 
         if build_obj and 'MOZ_HOST_BIN' in os.environ:
             options.xrePath = os.environ['MOZ_HOST_BIN']
 
         # Only reset the xrePath if it wasn't provided
         if options.xrePath is None:
             options.xrePath = options.utilityPath
 
--- a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
+++ b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
@@ -15,17 +15,16 @@ import subprocess
 import sys
 import telnetlib
 import time
 from distutils.spawn import find_executable
 
 import psutil
 import six.moves.urllib as urllib
 from mozdevice import ADBHost, ADBDevice
-from six.moves.urllib.parse import urlparse
 
 EMULATOR_HOME_DIR = os.path.join(os.path.expanduser('~'), '.mozbuild', 'android-device')
 
 EMULATOR_AUTH_FILE = os.path.join(os.path.expanduser('~'), '.emulator_console_auth_token')
 
 TOOLTOOL_PATH = 'testing/mozharness/external_tools/tooltool.py'
 
 TRY_URL = 'https://hg.mozilla.org/try/raw-file/default'
@@ -221,17 +220,17 @@ def verify_android_device(build_obj, ins
         # been forgotten.
         # If a test app is installed, there is no way to determine whether
         # the current build is installed, and certainly no way to
         # determine if the installed build is the desired build.
         # Installing every time (without prompting) is problematic because:
         #  - it prevents testing against other builds (downloaded apk)
         #  - installation may take a couple of minutes.
         if not app:
-            app = build_obj.substs["ANDROID_PACKAGE_NAME"]
+            app = "org.mozilla.geckoview.test"
         device = _get_device(build_obj.substs, device_serial)
         response = ''
         action = 'Re-install'
         installed = device.is_app_installed(app)
         if not installed:
             _log_info("It looks like %s is not installed on this device." % app)
             action = 'Install'
         if 'fennec' in app or 'firefox' in app:
@@ -326,53 +325,20 @@ def verify_android_device(build_obj, ins
 
     return device_verified
 
 
 def get_adb_path(build_obj):
     return _find_sdk_exe(build_obj.substs, 'adb', False)
 
 
-def run_firefox_for_android(build_obj, params, **kwargs):
-    """
-       Launch Firefox for Android on the connected device.
-       Optional 'params' allow parameters to be passed to Firefox.
-    """
-    device = _get_device(build_obj.substs)
-    try:
-        #
-        # Construct an adb command similar to:
-        #
-        # $ adb shell am start -a android.activity.MAIN \
-        #   -n org.mozilla.fennec_$USER \
-        #   -d <url param> \
-        #   --es args "<params>"
-        #
-        app = build_obj.substs['ANDROID_PACKAGE_NAME']
-
-        msg = "URL specified as '{}'; dropping URL-like parameter '{}'"
-        if params:
-            for p in params:
-                if urlparse.urlparse(p).scheme != "":
-                    params.remove(p)
-                    if kwargs.get('url'):
-                        _log_warning(msg.format(kwargs['url'], p))
-                    else:
-                        kwargs['url'] = p
-        device.launch_fennec(app, extra_args=params, **kwargs)
-    except Exception:
-        _log_warning("unable to launch Firefox for Android")
-        return 1
-    return 0
-
-
 def grant_runtime_permissions(build_obj, app, device_serial=None):
     """
     Grant required runtime permissions to the specified app
-    (typically org.mozilla.fennec_$USER).
+    (eg. org.mozilla.geckoview.test).
     """
     device = _get_device(build_obj.substs, device_serial)
     try:
         sdk_level = device.version
         if sdk_level and sdk_level >= 23:
             _log_info("Granting important runtime permissions to %s" % app)
             device.shell_output('pm grant %s android.permission.WRITE_EXTERNAL_STORAGE' % app)
             device.shell_output('pm grant %s android.permission.READ_EXTERNAL_STORAGE' % app)
--- a/testing/web-platform/mach_commands.py
+++ b/testing/web-platform/mach_commands.py
@@ -36,17 +36,17 @@ class WebPlatformTestsRunnerSetup(Mozbui
             sys.path.append(build_path)
 
     def kwargs_common(self, kwargs):
         tests_src_path = os.path.join(self._here, "tests")
         if kwargs["product"] == "fennec":
             # package_name may be non-fennec in the future
             package_name = kwargs["package_name"]
             if not package_name:
-                package_name = self.substs["ANDROID_PACKAGE_NAME"]
+                kwargs["package_name"] = package_name = "org.mozilla.geckoview.test"
 
             # Note that this import may fail in non-fennec trees
             from mozrunner.devices.android_device import verify_android_device, grant_runtime_permissions
             verify_android_device(self, install=True, verbose=False, xre=True, app=package_name)
 
             grant_runtime_permissions(self, package_name, kwargs["device_serial"])
             if kwargs["certutil_binary"] is None:
                 kwargs["certutil_binary"] = os.path.join(os.environ.get('MOZ_HOST_BIN'), "certutil")