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

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

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