Bug 1550052 - Ensure clean android app install via mach; r=jmaher

Uninstalling the test app before re-installing ensures a clean, predictable
starting state for gtest.

Differential Revision: https://phabricator.services.mozilla.com/D30407

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Geoff Brown 2019-05-08 20:38:47 +00:00
parent cbb89e0d8a
commit 5a5e4bf443

View File

@ -214,13 +214,13 @@ def verify_android_device(build_obj, install=False, xre=False, debugger=False,
break break
if device_verified and install: if device_verified and install:
# Determine if Firefox is installed on the device; if not, # Determine if test app is installed on the device; if not,
# prompt to install. This feature allows a test command to # prompt to install. This feature allows a test command to
# launch an emulator, install Firefox, and proceed with testing # launch an emulator, install the test app, and proceed with testing
# in one operation. It is also a basic safeguard against other # in one operation. It is also a basic safeguard against other
# cases where testing is requested but Firefox installation has # cases where testing is requested but test app installation has
# been forgotten. # been forgotten.
# If Firefox is installed, there is no way to determine whether # If a test app is installed, there is no way to determine whether
# the current build is installed, and certainly no way to # the current build is installed, and certainly no way to
# determine if the installed build is the desired build. # determine if the installed build is the desired build.
# Installing every time (without prompting) is problematic because: # Installing every time (without prompting) is problematic because:
@ -231,13 +231,16 @@ def verify_android_device(build_obj, install=False, xre=False, debugger=False,
device = _get_device(build_obj.substs, device_serial) device = _get_device(build_obj.substs, device_serial)
response = '' response = ''
action = 'Re-install' action = 'Re-install'
if not device.is_app_installed(app): installed = device.is_app_installed(app)
if not installed:
_log_info("It looks like %s is not installed on this device." % app) _log_info("It looks like %s is not installed on this device." % app)
action = 'Install' action = 'Install'
if 'fennec' in app or 'firefox' in app: if 'fennec' in app or 'firefox' in app:
response = response = raw_input( response = response = raw_input(
"%s Firefox? (Y/n) " % action).strip() "%s Firefox? (Y/n) " % action).strip()
if response.lower().startswith('y') or response == '': if response.lower().startswith('y') or response == '':
if installed:
device.uninstall_app(app)
_log_info("Installing Firefox. This may take a while...") _log_info("Installing Firefox. This may take a while...")
build_obj._run_make(directory=".", target='install', build_obj._run_make(directory=".", target='install',
ensure_exit_code=False) ensure_exit_code=False)
@ -245,6 +248,8 @@ def verify_android_device(build_obj, install=False, xre=False, debugger=False,
response = response = raw_input( response = response = raw_input(
"%s geckoview AndroidTest? (Y/n) " % action).strip() "%s geckoview AndroidTest? (Y/n) " % action).strip()
if response.lower().startswith('y') or response == '': if response.lower().startswith('y') or response == '':
if installed:
device.uninstall_app(app)
_log_info("Installing geckoview AndroidTest. This may take a while...") _log_info("Installing geckoview AndroidTest. This may take a while...")
sub = 'geckoview:installWithGeckoBinariesDebugAndroidTest' sub = 'geckoview:installWithGeckoBinariesDebugAndroidTest'
build_obj._mach_context.commands.dispatch('gradle', build_obj._mach_context.commands.dispatch('gradle',
@ -254,18 +259,19 @@ def verify_android_device(build_obj, install=False, xre=False, debugger=False,
response = response = raw_input( response = response = raw_input(
"%s geckoview_example? (Y/n) " % action).strip() "%s geckoview_example? (Y/n) " % action).strip()
if response.lower().startswith('y') or response == '': if response.lower().startswith('y') or response == '':
if installed:
device.uninstall_app(app)
_log_info("Installing geckoview_example. This may take a while...") _log_info("Installing geckoview_example. This may take a while...")
sub = 'install-geckoview_example' sub = 'install-geckoview_example'
build_obj._mach_context.commands.dispatch('android', build_obj._mach_context.commands.dispatch('android',
subcommand=sub, subcommand=sub,
args=[], args=[],
context=build_obj._mach_context) context=build_obj._mach_context)
else: elif not installed:
if not device.is_app_installed(app): response = raw_input(
response = raw_input( "It looks like %s is not installed on this device,\n"
"It looks like %s is not installed on this device,\n" "but I don't know how to install it.\n"
"but I don't know how to install it.\n" "Install it now, then hit Enter " % app)
"Install it now, then hit Enter " % app)
if device_verified and xre: if device_verified and xre:
# Check whether MOZ_HOST_BIN has been set to a valid xre; if not, # Check whether MOZ_HOST_BIN has been set to a valid xre; if not,