Bug 1292660 - Fix |mach mochitest| kwargs['app'] is None error on android, r?gbrown draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 05 Aug 2016 16:40:08 -0400
changeset 397830 03257548848f30155e7e99c5b7854b4cc90d790f
parent 397822 e78975b53563d80c99ebfbdf8a9fbf6b829a8a48
child 527557 9c7e3b7f699d985e4f2ae9f852dd7013c2912bea
push id25413
push userahalberstadt@mozilla.com
push dateMon, 08 Aug 2016 12:54:49 +0000
reviewersgbrown
bugs1292660, 1288827
milestone51.0a1
Bug 1292660 - Fix |mach mochitest| kwargs['app'] is None error on android, r?gbrown This fixes a regression from bug 1288827. It happened because I moved the logic that finds the application path a little later on in the test harness. But there was an instance where it was being used in the android mach command before that point. As it turned out, we don't really *need* that value there. This patch grabs the same value from build_obj.substs which is already an argument to the function. MozReview-Commit-ID: 3IsI4VzEIIF
layout/tools/reftest/mach_commands.py
testing/mochitest/mach_commands.py
testing/mozbase/mozrunner/mozrunner/devices/android_device.py
--- a/layout/tools/reftest/mach_commands.py
+++ b/layout/tools/reftest/mach_commands.py
@@ -246,17 +246,17 @@ class ReftestRunner(MozbuildObject):
             kwargs["app"] = self.substs["ANDROID_PACKAGE_NAME"]
         if not kwargs["utilityPath"]:
             kwargs["utilityPath"] = kwargs["xrePath"]
         kwargs["dm_trans"] = "adb"
         kwargs["ignoreWindowSize"] = True
         kwargs["printDeviceInfo"] = False
 
         from mozrunner.devices.android_device import grant_runtime_permissions
-        grant_runtime_permissions(self, kwargs['app'])
+        grant_runtime_permissions(self)
 
         # A symlink and some path manipulations are required so that test
         # manifests can be found both locally and remotely (via a url)
         # using the same relative path.
         if kwargs["suite"] == "jstestbrowser":
             staged_js_dir = os.path.join(self.topobjdir, "dist", "test-stage", "jsreftest")
             tests = os.path.join(self.reftest_dir, 'jsreftest')
             if not os.path.isdir(tests):
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -472,17 +472,17 @@ class MachCommands(MachCommandBase):
             print(SUPPORTED_TESTS_NOT_FOUND.format(
                 buildapp, '\n'.join(sorted(msg))))
             return 1
 
         if buildapp in ('b2g',):
             run_mochitest = mochitest.run_b2g_test
         elif buildapp == 'android':
             from mozrunner.devices.android_device import grant_runtime_permissions
-            grant_runtime_permissions(self, kwargs['app'])
+            grant_runtime_permissions(self)
             run_mochitest = mochitest.run_android_test
         else:
             run_mochitest = mochitest.run_desktop_test
 
         overall = None
         for (flavor, subsuite), tests in sorted(suites.items()):
             fobj = ALL_FLAVORS[flavor]
             msg = fobj['aliases'][0]
@@ -544,17 +544,17 @@ class RobocopCommands(MachCommandBase):
         driver.install_tests(tests)
 
         if len(tests) < 1:
             print(ROBOCOP_TESTS_NOT_FOUND.format('\n'.join(
                 sorted(list(test_paths)))))
             return 1
 
         from mozrunner.devices.android_device import grant_runtime_permissions
-        grant_runtime_permissions(self, kwargs['app'])
+        grant_runtime_permissions(self)
 
         mochitest = self._spawn(MochitestRunner)
         return mochitest.run_robocop_test(self._mach_context, tests, 'robocop', **kwargs)
 
 
 # NOTE python/mach/mach/commands/commandinfo.py references this function
 #      by name. If this function is renamed or removed, that file should
 #      be updated accordingly as well.
--- a/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
+++ b/testing/mozbase/mozrunner/mozrunner/devices/android_device.py
@@ -241,20 +241,21 @@ def run_firefox_for_android(build_obj, p
         _log_debug(cmd)
         output = dm.shellCheckOutput(cmd, timeout=10)
         _log_info(output)
     except DMError:
         _log_warning("unable to launch Firefox for Android")
         return 1
     return 0
 
-def grant_runtime_permissions(build_obj, app):
+def grant_runtime_permissions(build_obj):
     """
        Grant required runtime permissions to the specified app (typically org.mozilla.fennec_$USER).
     """
+    app = build_obj.substs['ANDROID_PACKAGE_NAME']
     adb_path = _find_sdk_exe(build_obj.substs, 'adb', False)
     if not adb_path:
         adb_path = 'adb'
     dm = DeviceManagerADB(autoconnect=False, adbPath=adb_path, retryLimit=1)
     dm.default_timeout = 10
     try:
         sdk_level = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
         if sdk_level and int(sdk_level) >= 23: