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

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

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 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
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 # 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
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)[0].hash 68 jar_md5 = md5sum.CalculateHostMd5Sums(self._jar_path)[self._jar_path]
69 if (d['JAR_MD5SUM'] == jar_md5 and 69 if (d['JAR_MD5SUM'] == jar_md5 and
70 d['VERSION'] == PICKLE_FORMAT_VERSION): 70 d['VERSION'] == PICKLE_FORMAT_VERSION):
71 self._test_methods = d['TEST_METHODS'] 71 self._test_methods = d['TEST_METHODS']
72 return True 72 return True
73 except: 73 except:
74 logging.warning('PICKLE_FORMAT_VERSION has changed, ignoring cache') 74 logging.warning('PICKLE_FORMAT_VERSION has changed, ignoring cache')
75 return False 75 return False
76 76
77 def _GetProguardData(self): 77 def _GetProguardData(self):
78 logging.info('Retrieving test methods via proguard.') 78 logging.info('Retrieving test methods via proguard.')
(...skipping 19 matching lines...) Expand all
98 for m in test_methods: 98 for m in test_methods:
99 qualified_method = '%s#%s' % (c['class'], m['method']) 99 qualified_method = '%s#%s' % (c['class'], m['method'])
100 annotations = dict(class_annotations) 100 annotations = dict(class_annotations)
101 annotations.update(m['annotations']) 101 annotations.update(m['annotations'])
102 self._test_methods[qualified_method] = m 102 self._test_methods[qualified_method] = m
103 self._test_methods[qualified_method]['annotations'] = annotations 103 self._test_methods[qualified_method]['annotations'] = annotations
104 104
105 logging.info('Storing proguard output to %s', self._pickled_proguard_name) 105 logging.info('Storing proguard output to %s', self._pickled_proguard_name)
106 d = {'VERSION': PICKLE_FORMAT_VERSION, 106 d = {'VERSION': PICKLE_FORMAT_VERSION,
107 'TEST_METHODS': self._test_methods, 107 'TEST_METHODS': self._test_methods,
108 'JAR_MD5SUM': md5sum.CalculateHostMd5Sums(self._jar_path)[0].hash} 108 'JAR_MD5SUM':
109 md5sum.CalculateHostMd5Sums(self._jar_path)[self._jar_path]}
109 with open(self._pickled_proguard_name, 'w') as f: 110 with open(self._pickled_proguard_name, 'w') as f:
110 f.write(pickle.dumps(d)) 111 f.write(pickle.dumps(d))
111 112
112 @staticmethod 113 @staticmethod
113 def _IsTestMethod(test): 114 def _IsTestMethod(test):
114 class_name, method = test.split('#') 115 class_name, method = test.split('#')
115 return class_name.endswith('Test') and method.startswith('test') 116 return class_name.endswith('Test') and method.startswith('test')
116 117
117 def GetTestAnnotations(self, test): 118 def GetTestAnnotations(self, test):
118 """Returns a list of all annotations for the given |test|. May be empty.""" 119 """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
218 devices = device_utils.DeviceUtils.parallel() 219 devices = device_utils.DeviceUtils.parallel()
219 min_sdk_version = min(devices.build_version_sdk.pGet(None)) 220 min_sdk_version = min(devices.build_version_sdk.pGet(None))
220 tests = [t for t in tests 221 tests = [t for t in tests
221 if self._IsTestValidForSdkRange(t, min_sdk_version)] 222 if self._IsTestValidForSdkRange(t, min_sdk_version)]
222 223
223 return tests 224 return tests
224 225
225 @staticmethod 226 @staticmethod
226 def IsHostDrivenTest(test): 227 def IsHostDrivenTest(test):
227 return 'pythonDrivenTests' in test 228 return 'pythonDrivenTests' in test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698