| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import fnmatch | 5 import fnmatch |
| 6 import functools | 6 import functools |
| 7 import logging | 7 import logging |
| 8 | 8 |
| 9 from devil import base_error |
| 9 from devil.android import device_errors | 10 from devil.android import device_errors |
| 10 from pylib import valgrind_tools | 11 from pylib import valgrind_tools |
| 11 from pylib.base import base_test_result | 12 from pylib.base import base_test_result |
| 12 from pylib.base import test_run | 13 from pylib.base import test_run |
| 13 from pylib.base import test_collection | 14 from pylib.base import test_collection |
| 14 | 15 |
| 15 | 16 |
| 16 def handle_shard_failures(f): | 17 def handle_shard_failures(f): |
| 17 """A decorator that handles device failures for per-device functions. | 18 """A decorator that handles device failures for per-device functions. |
| 18 | 19 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 31 Args: | 32 Args: |
| 32 f: the function being decorated. The function must take at least one | 33 f: the function being decorated. The function must take at least one |
| 33 argument, and that argument must be the device. | 34 argument, and that argument must be the device. |
| 34 on_failure: A binary function to call on failure. | 35 on_failure: A binary function to call on failure. |
| 35 """ | 36 """ |
| 36 def decorator(f): | 37 def decorator(f): |
| 37 @functools.wraps(f) | 38 @functools.wraps(f) |
| 38 def wrapper(dev, *args, **kwargs): | 39 def wrapper(dev, *args, **kwargs): |
| 39 try: | 40 try: |
| 40 return f(dev, *args, **kwargs) | 41 return f(dev, *args, **kwargs) |
| 41 except device_errors.CommandFailedError: | |
| 42 logging.exception('Shard failed: %s(%s)', f.__name__, str(dev)) | |
| 43 except device_errors.CommandTimeoutError: | 42 except device_errors.CommandTimeoutError: |
| 44 logging.exception('Shard timed out: %s(%s)', f.__name__, str(dev)) | 43 logging.exception('Shard timed out: %s(%s)', f.__name__, str(dev)) |
| 45 except device_errors.DeviceUnreachableError: | 44 except device_errors.DeviceUnreachableError: |
| 46 logging.exception('Shard died: %s(%s)', f.__name__, str(dev)) | 45 logging.exception('Shard died: %s(%s)', f.__name__, str(dev)) |
| 46 except base_error.BaseError: |
| 47 logging.exception('Shard failed: %s(%s)', f.__name__, |
| 48 str(dev)) |
| 47 if on_failure: | 49 if on_failure: |
| 48 on_failure(dev, f.__name__) | 50 on_failure(dev, f.__name__) |
| 49 return None | 51 return None |
| 50 | 52 |
| 51 return wrapper | 53 return wrapper |
| 52 | 54 |
| 53 return decorator | 55 return decorator |
| 54 | 56 |
| 55 | 57 |
| 56 class LocalDeviceTestRun(test_run.TestRun): | 58 class LocalDeviceTestRun(test_run.TestRun): |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 return test | 163 return test |
| 162 | 164 |
| 163 def _GetTests(self): | 165 def _GetTests(self): |
| 164 raise NotImplementedError | 166 raise NotImplementedError |
| 165 | 167 |
| 166 def _RunTest(self, device, test): | 168 def _RunTest(self, device, test): |
| 167 raise NotImplementedError | 169 raise NotImplementedError |
| 168 | 170 |
| 169 def _ShouldShard(self): | 171 def _ShouldShard(self): |
| 170 raise NotImplementedError | 172 raise NotImplementedError |
| OLD | NEW |