| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 logging | 5 import logging |
| 6 import re | 6 import re |
| 7 | 7 |
| 8 # http://developer.android.com/reference/android/test/InstrumentationTestRunner.
html | 8 # http://developer.android.com/reference/android/test/InstrumentationTestRunner.
html |
| 9 STATUS_CODE_START = 1 | 9 STATUS_CODE_START = 1 |
| 10 STATUS_CODE_OK = 0 | 10 STATUS_CODE_OK = 0 |
| 11 STATUS_CODE_ERROR = -1 | 11 STATUS_CODE_ERROR = -1 |
| 12 STATUS_CODE_FAILURE = -2 | 12 STATUS_CODE_FAILURE = -2 |
| 13 | 13 |
| 14 # http://developer.android.com/reference/android/app/Activity.html | 14 # http://developer.android.com/reference/android/app/Activity.html |
| 15 RESULT_CODE_OK = -1 | 15 RESULT_CODE_OK = -1 |
| 16 RESULT_CODE_CANCELED = 0 | 16 RESULT_CODE_CANCELED = 0 |
| 17 | 17 |
| 18 _INSTR_LINE_RE = re.compile('^\s*INSTRUMENTATION_([A-Z_]+): (.*)$') | 18 _INSTR_LINE_RE = re.compile(r'^\s*INSTRUMENTATION_([A-Z_]+): (.*)$') |
| 19 | 19 |
| 20 | 20 |
| 21 class InstrumentationParser(object): | 21 class InstrumentationParser(object): |
| 22 | 22 |
| 23 def __init__(self, stream): | 23 def __init__(self, stream): |
| 24 """An incremental parser for the output of Android instrumentation tests. | 24 """An incremental parser for the output of Android instrumentation tests. |
| 25 | 25 |
| 26 Example: | 26 Example: |
| 27 | 27 |
| 28 stream = adb.IterShell('am instrument -r ...') | 28 stream = adb.IterShell('am instrument -r ...') |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 may be None if no instrumentation result was found in the output. | 87 may be None if no instrumentation result was found in the output. |
| 88 | 88 |
| 89 Raises: | 89 Raises: |
| 90 AssertionError if attempting to get the instrumentation result before | 90 AssertionError if attempting to get the instrumentation result before |
| 91 exhausting |IterStatus| first. | 91 exhausting |IterStatus| first. |
| 92 """ | 92 """ |
| 93 assert self._bundle is not None, ( | 93 assert self._bundle is not None, ( |
| 94 'The IterStatus generator must be exhausted before reading the final' | 94 'The IterStatus generator must be exhausted before reading the final' |
| 95 ' instrumentation result.') | 95 ' instrumentation result.') |
| 96 return self._code, self._bundle | 96 return self._code, self._bundle |
| OLD | NEW |