| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 def _GetCachedProguardData(self): | 59 def _GetCachedProguardData(self): |
| 60 if (os.path.exists(self._pickled_proguard_name) and | 60 if (os.path.exists(self._pickled_proguard_name) and |
| 61 (os.path.getmtime(self._pickled_proguard_name) > | 61 (os.path.getmtime(self._pickled_proguard_name) > |
| 62 os.path.getmtime(self._jar_path))): | 62 os.path.getmtime(self._jar_path))): |
| 63 logging.info('Loading cached proguard output from %s', | 63 logging.info('Loading cached proguard output from %s', |
| 64 self._pickled_proguard_name) | 64 self._pickled_proguard_name) |
| 65 try: | 65 try: |
| 66 with open(self._pickled_proguard_name, 'r') as r: | 66 with open(self._pickled_proguard_name, 'r') as r: |
| 67 d = pickle.loads(r.read()) | 67 d = pickle.loads(r.read()) |
| 68 jar_md5 = md5sum.CalculateHostMd5Sums(self._jar_path)[self._jar_path] | 68 jar_md5 = md5sum.CalculateHostMd5Sums( |
| 69 self._jar_path)[os.path.realpath(self._jar_path)] |
| 69 if (d['JAR_MD5SUM'] == jar_md5 and | 70 if (d['JAR_MD5SUM'] == jar_md5 and |
| 70 d['VERSION'] == PICKLE_FORMAT_VERSION): | 71 d['VERSION'] == PICKLE_FORMAT_VERSION): |
| 71 self._test_methods = d['TEST_METHODS'] | 72 self._test_methods = d['TEST_METHODS'] |
| 72 return True | 73 return True |
| 73 except: | 74 except: |
| 74 logging.warning('PICKLE_FORMAT_VERSION has changed, ignoring cache') | 75 logging.warning('PICKLE_FORMAT_VERSION has changed, ignoring cache') |
| 75 return False | 76 return False |
| 76 | 77 |
| 77 def _GetProguardData(self): | 78 def _GetProguardData(self): |
| 78 logging.info('Retrieving test methods via proguard.') | 79 logging.info('Retrieving test methods via proguard.') |
| (...skipping 20 matching lines...) Expand all Loading... |
| 99 qualified_method = '%s#%s' % (c['class'], m['method']) | 100 qualified_method = '%s#%s' % (c['class'], m['method']) |
| 100 annotations = dict(class_annotations) | 101 annotations = dict(class_annotations) |
| 101 annotations.update(m['annotations']) | 102 annotations.update(m['annotations']) |
| 102 self._test_methods[qualified_method] = m | 103 self._test_methods[qualified_method] = m |
| 103 self._test_methods[qualified_method]['annotations'] = annotations | 104 self._test_methods[qualified_method]['annotations'] = annotations |
| 104 | 105 |
| 105 logging.info('Storing proguard output to %s', self._pickled_proguard_name) | 106 logging.info('Storing proguard output to %s', self._pickled_proguard_name) |
| 106 d = {'VERSION': PICKLE_FORMAT_VERSION, | 107 d = {'VERSION': PICKLE_FORMAT_VERSION, |
| 107 'TEST_METHODS': self._test_methods, | 108 'TEST_METHODS': self._test_methods, |
| 108 'JAR_MD5SUM': | 109 'JAR_MD5SUM': |
| 109 md5sum.CalculateHostMd5Sums(self._jar_path)[self._jar_path]} | 110 md5sum.CalculateHostMd5Sums( |
| 111 self._jar_path)[os.path.realpath(self._jar_path)]} |
| 110 with open(self._pickled_proguard_name, 'w') as f: | 112 with open(self._pickled_proguard_name, 'w') as f: |
| 111 f.write(pickle.dumps(d)) | 113 f.write(pickle.dumps(d)) |
| 112 | 114 |
| 113 @staticmethod | 115 @staticmethod |
| 114 def _IsTestMethod(test): | 116 def _IsTestMethod(test): |
| 115 class_name, method = test.split('#') | 117 class_name, method = test.split('#') |
| 116 return class_name.endswith('Test') and method.startswith('test') | 118 return class_name.endswith('Test') and method.startswith('test') |
| 117 | 119 |
| 118 def GetTestAnnotations(self, test): | 120 def GetTestAnnotations(self, test): |
| 119 """Returns a list of all annotations for the given |test|. May be empty.""" | 121 """Returns a list of all annotations for the given |test|. May be empty.""" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 devices = device_utils.DeviceUtils.parallel() | 221 devices = device_utils.DeviceUtils.parallel() |
| 220 min_sdk_version = min(devices.build_version_sdk.pGet(None)) | 222 min_sdk_version = min(devices.build_version_sdk.pGet(None)) |
| 221 tests = [t for t in tests | 223 tests = [t for t in tests |
| 222 if self._IsTestValidForSdkRange(t, min_sdk_version)] | 224 if self._IsTestValidForSdkRange(t, min_sdk_version)] |
| 223 | 225 |
| 224 return tests | 226 return tests |
| 225 | 227 |
| 226 @staticmethod | 228 @staticmethod |
| 227 def IsHostDrivenTest(test): | 229 def IsHostDrivenTest(test): |
| 228 return 'pythonDrivenTests' in test | 230 return 'pythonDrivenTests' in test |
| OLD | NEW |