Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: build/android/pylib/instrumentation/test_jar.py

Issue 153743008: Revert of Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merging with changes to pylib/linker/test_case.py. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
7 6
8 import collections 7 import collections
9 import logging 8 import logging
10 import os 9 import os
11 import pickle 10 import pickle
12 import re 11 import re
13 12
14 from pylib import cmd_helper 13 from pylib import cmd_helper
15 from pylib import constants 14 from pylib import constants
16 15
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 logging.info('Storing proguard output to %s', self._pickled_proguard_name) 120 logging.info('Storing proguard output to %s', self._pickled_proguard_name)
122 d = {'VERSION': PICKLE_FORMAT_VERSION, 121 d = {'VERSION': PICKLE_FORMAT_VERSION,
123 'ANNOTATION_MAP': self._annotation_map, 122 'ANNOTATION_MAP': self._annotation_map,
124 'TEST_METHODS': self._test_methods} 123 'TEST_METHODS': self._test_methods}
125 with open(self._pickled_proguard_name, 'w') as f: 124 with open(self._pickled_proguard_name, 'w') as f:
126 f.write(pickle.dumps(d)) 125 f.write(pickle.dumps(d))
127 126
128 def _GetAnnotationMap(self): 127 def _GetAnnotationMap(self):
129 return self._annotation_map 128 return self._annotation_map
130 129
131 @staticmethod 130 def _IsTestMethod(self, test):
132 def _IsTestMethod(test):
133 class_name, method = test.split('#') 131 class_name, method = test.split('#')
134 return class_name.endswith('Test') and method.startswith('test') 132 return class_name.endswith('Test') and method.startswith('test')
135 133
136 def GetTestAnnotations(self, test): 134 def GetTestAnnotations(self, test):
137 """Returns a list of all annotations for the given |test|. May be empty.""" 135 """Returns a list of all annotations for the given |test|. May be empty."""
138 if not self._IsTestMethod(test): 136 if not self._IsTestMethod(test):
139 return [] 137 return []
140 return self._GetAnnotationMap()[test] 138 return self._GetAnnotationMap()[test]
141 139
142 @staticmethod 140 def _AnnotationsMatchFilters(self, annotation_filter_list, annotations):
143 def _AnnotationsMatchFilters(annotation_filter_list, annotations):
144 """Checks if annotations match any of the filters.""" 141 """Checks if annotations match any of the filters."""
145 if not annotation_filter_list: 142 if not annotation_filter_list:
146 return True 143 return True
147 for annotation_filter in annotation_filter_list: 144 for annotation_filter in annotation_filter_list:
148 filters = annotation_filter.split('=') 145 filters = annotation_filter.split('=')
149 if len(filters) == 2: 146 if len(filters) == 2:
150 key = filters[0] 147 key = filters[0]
151 value_list = filters[1].split(',') 148 value_list = filters[1].split(',')
152 for value in value_list: 149 for value in value_list:
153 if key + ':' + value in annotations: 150 if key + ':' + value in annotations:
(...skipping 15 matching lines...) Expand all
169 def _GetTestsMissingAnnotation(self): 166 def _GetTestsMissingAnnotation(self):
170 """Get a list of test methods with no known annotations.""" 167 """Get a list of test methods with no known annotations."""
171 tests_missing_annotations = [] 168 tests_missing_annotations = []
172 for test_method in self.GetTestMethods(): 169 for test_method in self.GetTestMethods():
173 annotations_ = frozenset(self.GetTestAnnotations(test_method)) 170 annotations_ = frozenset(self.GetTestAnnotations(test_method))
174 if (annotations_.isdisjoint(self._ANNOTATIONS) and 171 if (annotations_.isdisjoint(self._ANNOTATIONS) and
175 not self.IsHostDrivenTest(test_method)): 172 not self.IsHostDrivenTest(test_method)):
176 tests_missing_annotations.append(test_method) 173 tests_missing_annotations.append(test_method)
177 return sorted(tests_missing_annotations) 174 return sorted(tests_missing_annotations)
178 175
179 def GetAllMatchingTests(self, annotation_filter_list, 176 def _GetAllMatchingTests(self, annotation_filter_list,
180 exclude_annotation_list, test_filter): 177 exclude_annotation_list, test_filter):
181 """Get a list of tests matching any of the annotations and the filter. 178 """Get a list of tests matching any of the annotations and the filter.
182 179
183 Args: 180 Args:
184 annotation_filter_list: List of test annotations. A test must have at 181 annotation_filter_list: List of test annotations. A test must have at
185 least one of these annotations. A test without any annotations is 182 least one of these annotations. A test without any annotations is
186 considered to be SmallTest. 183 considered to be SmallTest.
187 exclude_annotation_list: List of test annotations. A test must not have 184 exclude_annotation_list: List of test annotations. A test must not have
188 any of these annotations. 185 any of these annotations.
189 test_filter: Filter used for partial matching on the test method names. 186 test_filter: Filter used for partial matching on the test method names.
(...skipping 24 matching lines...) Expand all
214 tests = [t for t in available_tests 211 tests = [t for t in available_tests
215 if filter_without_hash in t.replace('#', '.')] 212 if filter_without_hash in t.replace('#', '.')]
216 else: 213 else:
217 tests = available_tests 214 tests = available_tests
218 215
219 return tests 216 return tests
220 217
221 @staticmethod 218 @staticmethod
222 def IsHostDrivenTest(test): 219 def IsHostDrivenTest(test):
223 return 'pythonDrivenTests' in test 220 return 'pythonDrivenTests' in test
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/setup.py ('k') | build/android/pylib/instrumentation/test_package.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698