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

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: 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..7fb5a98094a17e35ae90da39935045677e7dd184 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."""
@@ -50,6 +54,18 @@ class ApkInfo(object):
self._Initialize()
def _Initialize(self):
+ pickle_name = self._jar_path + "-proguard.pickle"
frankf 2012/11/22 03:03:48 single quotes here and below.
Yaron 2012/11/26 18:26:15 Done.
+ if os.path.exists(pickle_name) and (os.stat(pickle_name).st_mtime >
+ os.stat(self._jar_path).st_mtime):
frankf 2012/11/22 03:03:48 os.path.getmtime() is slightly preferred.
Yaron 2012/11/26 18:26:15 Done.
+ logging.info("Loading cached proguard output from %s", pickle_name)
bulach 2012/11/22 13:51:20 see below, probably best as: try: with open(pick
Yaron 2012/11/26 18:26:15 Done.
+ unpickler = pickle.Unpickler(open(pickle_name))
+ if PICKLE_FORMAT_VERSION == unpickler.load():
bulach 2012/11/22 13:51:20 prefer to pickle one dict, see below..
Yaron 2012/11/26 18:26:15 Done.
+ self._annotation_map = unpickler.load()
+ self._test_methods = unpickler.load()
+ return
+ else:
+ logging.warning("PICKLE_FORMAT_VERSION has changed, ignoring cache")
frankf 2012/11/22 03:03:48 Can you put this in a finally block with above lin
Yaron 2012/11/26 18:26:15 Done.
+
proguard_output = cmd_helper.GetCmdOutput([self._PROGUARD_PATH,
'-injars', self._jar_path,
'-dontshrink',
@@ -98,6 +114,12 @@ class ApkInfo(object):
annotation + ':' + value)
has_value = False
+ logging.info("Storing proguard output to %s", pickle_name)
+ pickler = pickle.Pickler(open(pickle_name, 'w'))
bulach 2012/11/22 13:51:20 pickle.dumps with a dict works better, no need for
Yaron 2012/11/26 18:26:15 Done.
+ pickler.dump(PICKLE_FORMAT_VERSION)
+ pickler.dump(self._annotation_map)
+ pickler.dump(self._test_methods)
+
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