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

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

Issue 14704006: Add option to exclude specific annotated Android instrumentation tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yet another typo fixed Created 7 years, 7 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 | Annotate | Revision Log
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 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 def _GetTestsMissingAnnotation(self): 166 def _GetTestsMissingAnnotation(self):
167 """Get a list of test methods with no known annotations.""" 167 """Get a list of test methods with no known annotations."""
168 tests_missing_annotations = [] 168 tests_missing_annotations = []
169 for test_method in self.GetTestMethods(): 169 for test_method in self.GetTestMethods():
170 annotations_ = frozenset(self.GetTestAnnotations(test_method)) 170 annotations_ = frozenset(self.GetTestAnnotations(test_method))
171 if (annotations_.isdisjoint(self._ANNOTATIONS) and 171 if (annotations_.isdisjoint(self._ANNOTATIONS) and
172 not self.IsPythonDrivenTest(test_method)): 172 not self.IsPythonDrivenTest(test_method)):
173 tests_missing_annotations.append(test_method) 173 tests_missing_annotations.append(test_method)
174 return sorted(tests_missing_annotations) 174 return sorted(tests_missing_annotations)
175 175
176 def _GetAllMatchingTests(self, annotation_filter_list, test_filter): 176 def _GetAllMatchingTests(self, annotation_filter_list,
177 exclude_annotation_list, test_filter):
177 """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.
178 179
179 Args: 180 Args:
180 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
181 least one of the these annotations. A test without any annotations 182 least one of these annotations. A test without any annotations is
182 is considered to be SmallTest. 183 considered to be SmallTest.
184 exclude_annotation_list: List of test annotations. A test must not have
185 any of these annotations.
183 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.
184 187
185 Returns: 188 Returns:
186 List of all matching tests. 189 List of all matching tests.
187 """ 190 """
188 if annotation_filter_list: 191 if annotation_filter_list:
189 available_tests = self.GetAnnotatedTests(annotation_filter_list) 192 available_tests = self.GetAnnotatedTests(annotation_filter_list)
190 # Include un-annotated tests in SmallTest. 193 # Include un-annotated tests in SmallTest.
191 if annotation_filter_list.count(self._DEFAULT_ANNOTATION) > 0: 194 if annotation_filter_list.count(self._DEFAULT_ANNOTATION) > 0:
192 for test in self._GetTestsMissingAnnotation(): 195 for test in self._GetTestsMissingAnnotation():
193 logging.warning( 196 logging.warning(
194 '%s has no annotations. Assuming "%s".', test, 197 '%s has no annotations. Assuming "%s".', test,
195 self._DEFAULT_ANNOTATION) 198 self._DEFAULT_ANNOTATION)
196 available_tests.append(test) 199 available_tests.append(test)
200 excluded_tests = self.GetAnnotatedTests(exclude_annotation_list)
201 available_tests = list(set(available_tests) - set(excluded_tests))
197 else: 202 else:
198 available_tests = [m for m in self.GetTestMethods() 203 available_tests = [m for m in self.GetTestMethods()
199 if not self.IsPythonDrivenTest(m)] 204 if not self.IsPythonDrivenTest(m)]
200 205
201 tests = [] 206 tests = []
202 if test_filter: 207 if test_filter:
203 # |available_tests| are in adb instrument format: package.path.class#test. 208 # |available_tests| are in adb instrument format: package.path.class#test.
204 filter_without_hash = test_filter.replace('#', '.') 209 filter_without_hash = test_filter.replace('#', '.')
205 tests = [t for t in available_tests 210 tests = [t for t in available_tests
206 if filter_without_hash in t.replace('#', '.')] 211 if filter_without_hash in t.replace('#', '.')]
207 else: 212 else:
208 tests = available_tests 213 tests = available_tests
209 214
210 return tests 215 return tests
211 216
212 @staticmethod 217 @staticmethod
213 def IsPythonDrivenTest(test): 218 def IsPythonDrivenTest(test):
214 return 'pythonDrivenTests' in test 219 return 'pythonDrivenTests' in test
OLDNEW
« no previous file with comments | « build/android/pylib/instrumentation/dispatch.py ('k') | build/android/pylib/utils/test_options_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698