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

Side by Side Diff: build/android/pylib/apk_info.py

Issue 11666023: Move android buildbot test logic into python (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reupload to fix copy detection on PRESUBMIT.py Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Gathers information about APKs.""" 5 """Gathers information about APKs."""
6 6
7 import collections 7 import collections
8 import constants
8 import logging 9 import logging
9 import os 10 import os
10 import pickle 11 import pickle
11 import re 12 import re
12 13
13 import cmd_helper 14 import cmd_helper
14 15
15 # If you change the cached output of proguard, increment this number 16 # If you change the cached output of proguard, increment this number
16 PICKLE_FORMAT_VERSION = 1 17 PICKLE_FORMAT_VERSION = 1
17 18
18 def GetPackageNameForApk(apk_path): 19 def GetPackageNameForApk(apk_path):
19 """Returns the package name of the apk file.""" 20 """Returns the package name of the apk file."""
20 aapt_output = cmd_helper.GetCmdOutput( 21 aapt_output = cmd_helper.GetCmdOutput(
21 ['aapt', 'dump', 'badging', apk_path]).split('\n') 22 ['aapt', 'dump', 'badging', apk_path]).split('\n')
22 package_name_re = re.compile(r'package: .*name=\'(\S*)\'') 23 package_name_re = re.compile(r'package: .*name=\'(\S*)\'')
23 for line in aapt_output: 24 for line in aapt_output:
24 m = package_name_re.match(line) 25 m = package_name_re.match(line)
25 if m: 26 if m:
26 return m.group(1) 27 return m.group(1)
27 raise Exception('Failed to determine package name of %s' % apk_path) 28 raise Exception('Failed to determine package name of %s' % apk_path)
28 29
29 30
30 class ApkInfo(object): 31 class ApkInfo(object):
31 """Helper class for inspecting APKs.""" 32 """Helper class for inspecting APKs."""
32 33
33 def __init__(self, apk_path, jar_path): 34 def __init__(self, apk_path, jar_path):
34 self._PROGUARD_PATH = os.path.join(os.environ['ANDROID_SDK_ROOT'], 35 sdk_root = os.getenv('ANDROID_SDK_ROOT', constants.ANDROID_SDK_ROOT)
36 self._PROGUARD_PATH = os.path.join(sdk_root,
35 'tools/proguard/bin/proguard.sh') 37 'tools/proguard/bin/proguard.sh')
36 if not os.path.exists(self._PROGUARD_PATH): 38 if not os.path.exists(self._PROGUARD_PATH):
37 self._PROGUARD_PATH = os.path.join(os.environ['ANDROID_BUILD_TOP'], 39 self._PROGUARD_PATH = os.path.join(os.environ['ANDROID_BUILD_TOP'],
38 'external/proguard/bin/proguard.sh') 40 'external/proguard/bin/proguard.sh')
39 self._PROGUARD_CLASS_RE = re.compile(r'\s*?- Program class:\s*([\S]+)$') 41 self._PROGUARD_CLASS_RE = re.compile(r'\s*?- Program class:\s*([\S]+)$')
40 self._PROGUARD_METHOD_RE = re.compile(r'\s*?- Method:\s*(\S*)[(].*$') 42 self._PROGUARD_METHOD_RE = re.compile(r'\s*?- Method:\s*(\S*)[(].*$')
41 self._PROGUARD_ANNOTATION_RE = re.compile(r'\s*?- Annotation \[L(\S*);\]:$') 43 self._PROGUARD_ANNOTATION_RE = re.compile(r'\s*?- Annotation \[L(\S*);\]:$')
42 self._PROGUARD_ANNOTATION_CONST_RE = ( 44 self._PROGUARD_ANNOTATION_CONST_RE = (
43 re.compile(r'\s*?- Constant element value.*$')) 45 re.compile(r'\s*?- Constant element value.*$'))
44 self._PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$') 46 self._PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$')
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if self._IsTestMethod(test) and self._AnnotationsMatchFilters( 179 if self._IsTestMethod(test) and self._AnnotationsMatchFilters(
178 annotation_filter_list, annotations)] 180 annotation_filter_list, annotations)]
179 181
180 def GetTestMethods(self): 182 def GetTestMethods(self):
181 """Returns a list of all test methods in this apk as Class#testMethod.""" 183 """Returns a list of all test methods in this apk as Class#testMethod."""
182 return self._test_methods 184 return self._test_methods
183 185
184 @staticmethod 186 @staticmethod
185 def IsPythonDrivenTest(test): 187 def IsPythonDrivenTest(test):
186 return 'pythonDrivenTests' in test 188 return 'pythonDrivenTests' in test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698