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

Unified Diff: build/android/pylib/apk_info.py

Issue 11421040: Make repeated running of instrumentation tests faster. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: frank's nits Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/apk_info.py
diff --git a/build/android/pylib/apk_info.py b/build/android/pylib/apk_info.py
index 6b0b7f63e68430d02eca6a264a4ea3b50717993f..2040f2444ccf59a48563356db7d29bfe051a400f 100644
--- a/build/android/pylib/apk_info.py
+++ b/build/android/pylib/apk_info.py
@@ -5,11 +5,15 @@
"""Gathers information about APKs."""
import collections
+import logging
import os
+import pickle
import re
import cmd_helper
+# If you change the cached output of proguard, increment this number
+PICKLE_FORMAT_VERSION = 1
def GetPackageNameForApk(apk_path):
"""Returns the package name of the apk file."""
@@ -46,10 +50,32 @@ class ApkInfo(object):
raise Exception('%s not found, please build it' % jar_path)
self._jar_path = jar_path
self._annotation_map = collections.defaultdict(list)
+ self._pickled_proguard_name = self._jar_path + '-proguard.pickle'
self._test_methods = []
self._Initialize()
def _Initialize(self):
+ if not self._GetCachedProguardData():
+ self._GetProguardData()
+
+ def _GetCachedProguardData(self):
+ if (os.path.exists(self._pickled_proguard_name) and
+ (os.path.getmtime(self._pickled_proguard_name) >
+ os.path.getmtime(self._jar_path))):
+ logging.info('Loading cached proguard output from %s',
+ self._pickled_proguard_name)
+ try:
+ with open(self._pickled_proguard_name, 'r') as r:
+ d = pickle.loads(r.read())
+ if d['VERSION'] == PICKLE_FORMAT_VERSION:
+ self._annotation_map = d['ANNOTATION_MAP']
+ self._test_methods = d['TEST_METHODS']
+ return True
+ except:
+ logging.warning('PICKLE_FORMAT_VERSION has changed, ignoring cache')
+ return False
+
+ def _GetProguardData(self):
proguard_output = cmd_helper.GetCmdOutput([self._PROGUARD_PATH,
'-injars', self._jar_path,
'-dontshrink',
@@ -98,6 +124,13 @@ class ApkInfo(object):
annotation + ':' + value)
has_value = False
+ logging.info('Storing proguard output to %s', self._pickled_proguard_name)
+ d = {'VERSION': PICKLE_FORMAT_VERSION,
+ 'ANNOTATION_MAP': self._annotation_map,
+ 'TEST_METHODS': self._test_methods}
+ with open(self._pickled_proguard_name, 'w') as f:
+ f.write(pickle.dumps(d))
+
def _GetAnnotationMap(self):
return self._annotation_map
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698