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

Unified Diff: build/android/pylib/utils/proguard.py

Issue 1353673004: Add some unit tests for pylib.utils.proguard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split into separate tests Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/constants/__init__.py ('k') | build/android/pylib/utils/proguard_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/proguard.py
diff --git a/build/android/pylib/utils/proguard.py b/build/android/pylib/utils/proguard.py
index 91ded9923b7b0d189ef5db9d59c8790bc333753d..251cc4de46368436e8c8075d2774cdaebb0adc32 100644
--- a/build/android/pylib/utils/proguard.py
+++ b/build/android/pylib/utils/proguard.py
@@ -67,82 +67,81 @@ def Dump(jar_path):
'-dontobfuscate',
'-dontpreverify',
'-dump', proguard_output.name])
-
-
- results = {
- 'classes': [],
- }
-
- annotation = None
- annotation_has_value = False
- class_result = None
- method_result = None
-
- for line in proguard_output:
- line = line.strip('\r\n')
-
- m = _PROGUARD_CLASS_RE.match(line)
- if m:
- class_result = {
- 'class': m.group(1).replace('/', '.'),
- 'superclass': '',
- 'annotations': {},
- 'methods': [],
- }
- results['classes'].append(class_result)
- annotation = None
- annotation_has_value = False
- method_result = None
- continue
-
- if not class_result:
- continue
-
- m = _PROGUARD_SUPERCLASS_RE.match(line)
- if m:
- class_result['superclass'] = m.group(1).replace('/', '.')
- continue
-
- m = _PROGUARD_SECTION_RE.match(line)
- if m:
- annotation = None
- annotation_has_value = False
- method_result = None
- continue
-
- m = _PROGUARD_METHOD_RE.match(line)
- if m:
- method_result = {
- 'method': m.group(1),
- 'annotations': {},
- }
- class_result['methods'].append(method_result)
- annotation = None
- annotation_has_value = False
- continue
-
- m = _PROGUARD_ANNOTATION_RE.match(line)
- if m:
- # Ignore the annotation package.
- annotation = m.group(1).split('/')[-1]
- if method_result:
- method_result['annotations'][annotation] = None
- else:
- class_result['annotations'][annotation] = None
- continue
-
- if annotation:
- if not annotation_has_value:
- m = _PROGUARD_ANNOTATION_CONST_RE.match(line)
- annotation_has_value = bool(m)
- else:
- m = _PROGUARD_ANNOTATION_VALUE_RE.match(line)
- if m:
- if method_result:
- method_result['annotations'][annotation] = m.group(1)
- else:
- class_result['annotations'][annotation] = m.group(1)
- annotation_has_value = None
-
+ return Parse(proguard_output)
+
+def Parse(proguard_output):
+ results = {
+ 'classes': [],
+ }
+
+ annotation = None
+ annotation_has_value = False
+ class_result = None
+ method_result = None
+
+ for line in proguard_output:
+ line = line.strip('\r\n')
+
+ m = _PROGUARD_CLASS_RE.match(line)
+ if m:
+ class_result = {
+ 'class': m.group(1).replace('/', '.'),
+ 'superclass': '',
+ 'annotations': {},
+ 'methods': [],
+ }
+ results['classes'].append(class_result)
+ annotation = None
+ annotation_has_value = False
+ method_result = None
+ continue
+
+ if not class_result:
+ continue
+
+ m = _PROGUARD_SUPERCLASS_RE.match(line)
+ if m:
+ class_result['superclass'] = m.group(1).replace('/', '.')
+ continue
+
+ m = _PROGUARD_SECTION_RE.match(line)
+ if m:
+ annotation = None
+ annotation_has_value = False
+ method_result = None
+ continue
+
+ m = _PROGUARD_METHOD_RE.match(line)
+ if m:
+ method_result = {
+ 'method': m.group(1),
+ 'annotations': {},
+ }
+ class_result['methods'].append(method_result)
+ annotation = None
+ annotation_has_value = False
+ continue
+
+ m = _PROGUARD_ANNOTATION_RE.match(line)
+ if m:
+ # Ignore the annotation package.
+ annotation = m.group(1).split('/')[-1]
+ if method_result:
+ method_result['annotations'][annotation] = None
+ else:
+ class_result['annotations'][annotation] = None
+ continue
+
+ if annotation:
+ if not annotation_has_value:
+ m = _PROGUARD_ANNOTATION_CONST_RE.match(line)
+ annotation_has_value = bool(m)
+ else:
+ m = _PROGUARD_ANNOTATION_VALUE_RE.match(line)
+ if m:
+ if method_result:
+ method_result['annotations'][annotation] = m.group(1)
+ else:
+ class_result['annotations'][annotation] = m.group(1)
+ annotation_has_value = None
return results
-
« no previous file with comments | « build/android/pylib/constants/__init__.py ('k') | build/android/pylib/utils/proguard_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698