OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 """Helper class for instrumenation test jar.""" | 5 """Helper class for instrumenation test jar.""" |
6 # pylint: disable=W0702 | 6 # pylint: disable=W0702 |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import pickle | 10 import pickle |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 def _AnnotationsMatchFilters(annotation_filter_list, annotations): | 133 def _AnnotationsMatchFilters(annotation_filter_list, annotations): |
134 """Checks if annotations match any of the filters.""" | 134 """Checks if annotations match any of the filters.""" |
135 if not annotation_filter_list: | 135 if not annotation_filter_list: |
136 return True | 136 return True |
137 for annotation_filter in annotation_filter_list: | 137 for annotation_filter in annotation_filter_list: |
138 filters = annotation_filter.split('=') | 138 filters = annotation_filter.split('=') |
139 if len(filters) == 2: | 139 if len(filters) == 2: |
140 key = filters[0] | 140 key = filters[0] |
141 value_list = filters[1].split(',') | 141 value_list = filters[1].split(',') |
142 for value in value_list: | 142 for value in value_list: |
143 if key in annotations and value == annotations['key']: | 143 if key in annotations and value == annotations[key]: |
144 return True | 144 return True |
145 elif annotation_filter in annotations: | 145 elif annotation_filter in annotations: |
146 return True | 146 return True |
147 return False | 147 return False |
148 | 148 |
149 def GetAnnotatedTests(self, annotation_filter_list): | 149 def GetAnnotatedTests(self, annotation_filter_list): |
150 """Returns a list of all tests that match the given annotation filters.""" | 150 """Returns a list of all tests that match the given annotation filters.""" |
151 return [test for test in self.GetTestMethods() | 151 return [test for test in self.GetTestMethods() |
152 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( | 152 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( |
153 annotation_filter_list, self.GetTestAnnotations(test))] | 153 annotation_filter_list, self.GetTestAnnotations(test))] |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 'ro.build.version.sdk').pGet(None)] | 230 'ro.build.version.sdk').pGet(None)] |
231 tests = filter( | 231 tests = filter( |
232 lambda t: self._IsTestValidForSdkRange(t, min(sdk_versions)), | 232 lambda t: self._IsTestValidForSdkRange(t, min(sdk_versions)), |
233 tests) | 233 tests) |
234 | 234 |
235 return tests | 235 return tests |
236 | 236 |
237 @staticmethod | 237 @staticmethod |
238 def IsHostDrivenTest(test): | 238 def IsHostDrivenTest(test): |
239 return 'pythonDrivenTests' in test | 239 return 'pythonDrivenTests' in test |
OLD | NEW |