Commit adfdeeea authored by zhaoyangli's avatar zhaoyangli Committed by Commit Bot

[iOS][infra] Use a separated exit code for device errors in test runner.

Since this change, device issue is distinguished from other test runner
errors, so that devices will be marked unavailable only when the error
is related with device.

Bug: 1078416
Change-Id: I340ebb202145660cae799c34be5471c398b3c394
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2311147Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Zhaoyang Li <zhaoyangli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790929}
parent f830da38
......@@ -207,6 +207,14 @@ class Runner():
)
return 0 if tr.launch() else 1
except test_runner.DeviceError as e:
sys.stderr.write(traceback.format_exc())
summary['step_text'] = '%s%s' % (e.__class__.__name__,
': %s' % e.args[0] if e.args else '')
# Swarming infra marks device status unavailable for any device related
# issue using this return code.
return 3
except test_runner.TestRunnerError as e:
sys.stderr.write(traceback.format_exc())
summary['step_text'] = '%s%s' % (e.__class__.__name__,
......
......@@ -49,6 +49,11 @@ class TestRunnerError(Error):
pass
class DeviceError(TestRunnerError):
"""Base class for physical device related errors."""
pass
class AppLaunchError(TestRunnerError):
"""The app failed to launch."""
pass
......@@ -61,21 +66,21 @@ class AppNotFoundError(TestRunnerError):
'App does not exist: %s' % app_path)
class SystemAlertPresentError(TestRunnerError):
class SystemAlertPresentError(DeviceError):
"""System alert is shown on the device."""
def __init__(self):
super(SystemAlertPresentError, self).__init__(
'System alert is shown on the device.')
class DeviceDetectionError(TestRunnerError):
class DeviceDetectionError(DeviceError):
"""Unexpected number of devices detected."""
def __init__(self, udids):
super(DeviceDetectionError, self).__init__(
'Expected one device, found %s:\n%s' % (len(udids), '\n'.join(udids)))
class DeviceRestartError(TestRunnerError):
class DeviceRestartError(DeviceError):
"""Error restarting a device."""
def __init__(self):
super(DeviceRestartError, self).__init__('Error restarting a device')
......@@ -95,7 +100,7 @@ class SimulatorNotFoundError(TestRunnerError):
'Simulator does not exist: %s' % iossim_path)
class TestDataExtractionError(TestRunnerError):
class TestDataExtractionError(DeviceError):
"""Error extracting test data or crash reports from a device."""
def __init__(self):
super(TestDataExtractionError, self).__init__('Failed to extract test data')
......
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