OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Gathers information about APKs.""" | 5 """Gathers information about APKs.""" |
6 | 6 |
7 import collections | 7 import collections |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import pickle | 10 import pickle |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 method = None | 88 method = None |
89 annotation = None | 89 annotation = None |
90 has_value = False | 90 has_value = False |
91 qualified_method = None | 91 qualified_method = None |
92 for line in proguard_output: | 92 for line in proguard_output: |
93 m = self._PROGUARD_CLASS_RE.match(line) | 93 m = self._PROGUARD_CLASS_RE.match(line) |
94 if m: | 94 if m: |
95 clazz = m.group(1).replace('/', '.') # Change package delim. | 95 clazz = m.group(1).replace('/', '.') # Change package delim. |
96 annotation = None | 96 annotation = None |
97 continue | 97 continue |
| 98 |
98 m = self._PROGUARD_METHOD_RE.match(line) | 99 m = self._PROGUARD_METHOD_RE.match(line) |
99 if m: | 100 if m: |
100 method = m.group(1) | 101 method = m.group(1) |
101 annotation = None | 102 annotation = None |
102 qualified_method = clazz + '#' + method | 103 qualified_method = clazz + '#' + method |
103 if method.startswith('test') and clazz.endswith('Test'): | 104 if method.startswith('test') and clazz.endswith('Test'): |
104 self._test_methods += [qualified_method] | 105 self._test_methods += [qualified_method] |
105 continue | 106 continue |
| 107 |
| 108 if not qualified_method: |
| 109 # Ignore non-method annotations. |
| 110 continue |
| 111 |
106 m = self._PROGUARD_ANNOTATION_RE.match(line) | 112 m = self._PROGUARD_ANNOTATION_RE.match(line) |
107 if m: | 113 if m: |
108 assert qualified_method | |
109 annotation = m.group(1).split('/')[-1] # Ignore the annotation package. | 114 annotation = m.group(1).split('/')[-1] # Ignore the annotation package. |
110 self._annotation_map[qualified_method].append(annotation) | 115 self._annotation_map[qualified_method].append(annotation) |
111 has_value = False | 116 has_value = False |
112 continue | 117 continue |
113 if annotation: | 118 if annotation: |
114 assert qualified_method | |
115 if not has_value: | 119 if not has_value: |
116 m = self._PROGUARD_ANNOTATION_CONST_RE.match(line) | 120 m = self._PROGUARD_ANNOTATION_CONST_RE.match(line) |
117 if m: | 121 if m: |
118 has_value = True | 122 has_value = True |
119 else: | 123 else: |
120 m = self._PROGUARD_ANNOTATION_VALUE_RE.match(line) | 124 m = self._PROGUARD_ANNOTATION_VALUE_RE.match(line) |
121 if m: | 125 if m: |
122 value = m.group(1) | 126 value = m.group(1) |
123 self._annotation_map[qualified_method].append( | 127 self._annotation_map[qualified_method].append( |
124 annotation + ':' + value) | 128 annotation + ':' + value) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( | 177 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( |
174 annotation_filter_list, annotations)] | 178 annotation_filter_list, annotations)] |
175 | 179 |
176 def GetTestMethods(self): | 180 def GetTestMethods(self): |
177 """Returns a list of all test methods in this apk as Class#testMethod.""" | 181 """Returns a list of all test methods in this apk as Class#testMethod.""" |
178 return self._test_methods | 182 return self._test_methods |
179 | 183 |
180 @staticmethod | 184 @staticmethod |
181 def IsPythonDrivenTest(test): | 185 def IsPythonDrivenTest(test): |
182 return 'pythonDrivenTests' in test | 186 return 'pythonDrivenTests' in test |
OLD | NEW |