Commit dac916ed authored by Jeff Yoon's avatar Jeff Yoon Committed by Commit Bot

[ios] Ensure erase and shutdown sim calls are succeeding.

Change subprocess.call to check_call such that the non-zero exit
codes are throwing subprocess error accordingly.

Change-Id: I71597e3e48c0908ea10e98281f6843ae23308250
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310894
Commit-Queue: Jeff Yoon <jeffyoon@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790633}
parent d33f0085
...@@ -116,7 +116,14 @@ def delete_simulator_by_udid(udid): ...@@ -116,7 +116,14 @@ def delete_simulator_by_udid(udid):
udid: (str) UDID of simulator. udid: (str) UDID of simulator.
""" """
LOGGER.info('Deleting simulator %s', udid) LOGGER.info('Deleting simulator %s', udid)
subprocess.call(['xcrun', 'simctl', 'delete', udid]) try:
subprocess.check_output(['xcrun', 'simctl', 'delete', udid],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
# Logging error instead of throwing so we don't cause failures in case
# this was indeed failing to clean up.
message = 'Failed to delete simulator %s with error %s' % (udid, e.output)
LOGGER.error(message)
def wipe_simulator_by_udid(udid): def wipe_simulator_by_udid(udid):
...@@ -134,7 +141,7 @@ def wipe_simulator_by_udid(udid): ...@@ -134,7 +141,7 @@ def wipe_simulator_by_udid(udid):
if device['state'] != 'Shutdown': if device['state'] != 'Shutdown':
subprocess.check_call(['xcrun', 'simctl', 'shutdown', device['udid']]) subprocess.check_call(['xcrun', 'simctl', 'shutdown', device['udid']])
except subprocess.CalledProcessError as ex: except subprocess.CalledProcessError as ex:
LOGGER.info('Shutdown failed %s ', ex) LOGGER.error('Shutdown failed %s ', ex)
subprocess.check_call(['xcrun', 'simctl', 'erase', device['udid']]) subprocess.check_call(['xcrun', 'simctl', 'erase', device['udid']])
......
...@@ -43,8 +43,6 @@ def erase_all_simulators(path=None): ...@@ -43,8 +43,6 @@ def erase_all_simulators(path=None):
Args: Args:
path: (str) A path with simulators path: (str) A path with simulators
Fix for DVTCoreSimulatorAdditionsErrorDomain error.
""" """
command = ['xcrun', 'simctl'] command = ['xcrun', 'simctl']
if path: if path:
...@@ -52,16 +50,23 @@ def erase_all_simulators(path=None): ...@@ -52,16 +50,23 @@ def erase_all_simulators(path=None):
LOGGER.info('Erasing all simulators from folder %s.' % path) LOGGER.info('Erasing all simulators from folder %s.' % path)
else: else:
LOGGER.info('Erasing all simulators.') LOGGER.info('Erasing all simulators.')
subprocess.call(command + ['erase', 'all'])
try:
subprocess.check_call(command + ['erase', 'all'])
except subprocess.CalledProcessError as e:
# Logging error instead of throwing so we don't cause failures in case
# this was indeed failing to clean up.
message = 'Failed to erase all simulators. Error: %s' % e.output
LOGGER.error(message)
def shutdown_all_simulators(path=None): def shutdown_all_simulators(path=None):
"""Shutdown all simulator devices. """Shutdown all simulator devices.
Fix for DVTCoreSimulatorAdditionsErrorDomain error.
Args: Args:
path: (str) A path with simulators path: (str) A path with simulators
Fix for DVTCoreSimulatorAdditionsErrorDomain error.
""" """
command = ['xcrun', 'simctl'] command = ['xcrun', 'simctl']
if path: if path:
...@@ -69,7 +74,14 @@ def shutdown_all_simulators(path=None): ...@@ -69,7 +74,14 @@ def shutdown_all_simulators(path=None):
LOGGER.info('Shutdown all simulators from folder %s.' % path) LOGGER.info('Shutdown all simulators from folder %s.' % path)
else: else:
LOGGER.info('Shutdown all simulators.') LOGGER.info('Shutdown all simulators.')
subprocess.call(command + ['shutdown', 'all'])
try:
subprocess.check_call(command + ['shutdown', 'all'])
except subprocess.CalledProcessError as e:
# Logging error instead of throwing so we don't cause failures in case
# this was indeed failing to clean up.
message = 'Failed to shutdown all simulators. Error: %s' % e.output
LOGGER.error(message)
def terminate_process(proc): def terminate_process(proc):
...@@ -83,7 +95,7 @@ def terminate_process(proc): ...@@ -83,7 +95,7 @@ def terminate_process(proc):
try: try:
proc.terminate() proc.terminate()
except OSError as ex: except OSError as ex:
LOGGER.info('Error while killing a process: %s' % ex) LOGGER.error('Error while killing a process: %s' % ex)
class LaunchCommand(object): class LaunchCommand(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment