From 1a23bd03a228d2604f09015d2d66bbbe92d9a224 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Mon, 19 Sep 2016 13:41:22 +0100 Subject: [PATCH] runner: Some types of exceptions will no longer take screenshots or dump UI hiarchy For resource or Host errors (error which are not caused by the target). the runner will no longer take screenshots ect as these are meaningless. --- wlauto/core/execution.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/wlauto/core/execution.py b/wlauto/core/execution.py index 0f3d9cd8..bc1e1acd 100644 --- a/wlauto/core/execution.py +++ b/wlauto/core/execution.py @@ -56,7 +56,8 @@ from wlauto.core.extension_loader import ExtensionLoader from wlauto.core.resolver import ResourceResolver from wlauto.core.result import ResultManager, IterationResult, RunResult from wlauto.exceptions import (WAError, ConfigError, TimeoutError, InstrumentError, - DeviceError, DeviceNotRespondingError) + DeviceError, DeviceNotRespondingError, ResourceError, + HostError) from wlauto.utils.misc import ensure_directory_exists as _d, get_traceback, merge_dicts, format_duration @@ -756,17 +757,21 @@ class Runner(object): if self.current_job: self.current_job.result.status = on_error_status self.current_job.result.add_event(str(we)) - try: - self._take_screenshot('error.png') - if self.device.platform == 'android': - self._take_uiautomator_dump('error.xml') - except Exception, e: # pylint: disable=W0703 - # We're already in error state, so the fact that taking a - # screenshot failed is not surprising... - pass + + # There is no point in taking a screenshot ect if the issue is not + # with the device but with the host or a missing resource + if not (isinstance(we, ResourceError) or isinstance(we, HostError)): + try: + self._take_screenshot('error.png') + if self.device.platform == 'android': + self._take_uiautomator_dump('error.xml') + except Exception, e: # pylint: disable=W0703 + # We're already in error state, so the fact that taking a + # screenshot failed is not surprising... + pass if action: action = action[0].lower() + action[1:] - self.logger.error('Error while {}:\n\t{}'.format(action, we)) + self.logger.error('Error while {}:\n\t{}'.format(action, str(we).replace("\n", "\n\t"))) except Exception, e: # pylint: disable=W0703 error_text = '{}("{}")'.format(e.__class__.__name__, e) if self.current_job: