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 | 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 |
11 import re | 11 import re |
12 import sys | |
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 |
17 sys.path.insert(0, | |
18 os.path.join(constants.DIR_SOURCE_ROOT, | |
19 'build', 'util', 'lib', 'common')) | |
20 | |
21 import unittest_util | |
16 | 22 |
17 # If you change the cached output of proguard, increment this number | 23 # If you change the cached output of proguard, increment this number |
18 PICKLE_FORMAT_VERSION = 1 | 24 PICKLE_FORMAT_VERSION = 1 |
19 | 25 |
20 | 26 |
21 class TestJar(object): | 27 class TestJar(object): |
22 _ANNOTATIONS = frozenset( | 28 _ANNOTATIONS = frozenset( |
23 ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', | 29 ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', |
24 'FlakyTest', 'DisabledTest', 'Manual', 'PerfTest', 'HostDrivenTest']) | 30 'FlakyTest', 'DisabledTest', 'Manual', 'PerfTest', 'HostDrivenTest']) |
25 _DEFAULT_ANNOTATION = 'SmallTest' | 31 _DEFAULT_ANNOTATION = 'SmallTest' |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 if exclude_annotation_list: | 206 if exclude_annotation_list: |
201 excluded_tests = self.GetAnnotatedTests(exclude_annotation_list) | 207 excluded_tests = self.GetAnnotatedTests(exclude_annotation_list) |
202 available_tests = list(set(available_tests) - set(excluded_tests)) | 208 available_tests = list(set(available_tests) - set(excluded_tests)) |
203 else: | 209 else: |
204 available_tests = [m for m in self.GetTestMethods() | 210 available_tests = [m for m in self.GetTestMethods() |
205 if not self.IsHostDrivenTest(m)] | 211 if not self.IsHostDrivenTest(m)] |
206 | 212 |
207 tests = [] | 213 tests = [] |
208 if test_filter: | 214 if test_filter: |
209 # |available_tests| are in adb instrument format: package.path.class#test. | 215 # |available_tests| are in adb instrument format: package.path.class#test. |
210 filter_without_hash = test_filter.replace('#', '.') | 216 |
211 tests = [t for t in available_tests | 217 # Maps a 'class.test' name to each 'package.path.class#test' name. |
212 if filter_without_hash in t.replace('#', '.')] | 218 sanitized_test_names = { |
219 t.split('.')[-1].replace('#', '.') : t for t in available_tests} | |
frankf
2014/01/22 22:14:11
dictionary comprehension is only python 2.7+ right
| |
220 # Filters 'class.test' names and populates |tests| with the corresponding | |
221 # 'package.path.class#test' names. | |
222 tests = [sanitized_test_names[t] for t in | |
223 unittest_util.FilterTestNames( | |
224 sanitized_test_names.keys(), | |
225 test_filter.replace('#', '.'))] | |
frankf
2014/01/22 22:14:11
this is pretty unreadable, can you tweak the white
| |
213 else: | 226 else: |
214 tests = available_tests | 227 tests = available_tests |
215 | 228 |
216 return tests | 229 return tests |
217 | 230 |
218 @staticmethod | 231 @staticmethod |
219 def IsHostDrivenTest(test): | 232 def IsHostDrivenTest(test): |
220 return 'pythonDrivenTests' in test | 233 return 'pythonDrivenTests' in test |
OLD | NEW |