Commit 5cf6316c authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

Check for testing methods in final apk in android-binary-size tryjob

This cl checks for methods named 'ForTest' in the final release apk.

Bug: 1012373
Change-Id: I33afb2eeb0726bc8d2c66bec779a4950753a5250
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879604
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709593}
parent 2d93c955
...@@ -68,7 +68,9 @@ _TEST_ONLY_WARNING = ( ...@@ -68,7 +68,9 @@ _TEST_ONLY_WARNING = (
'You might be calling functions intended only for testing from\n' 'You might be calling functions intended only for testing from\n'
'production code. It is OK to ignore this warning if you know what\n' 'production code. It is OK to ignore this warning if you know what\n'
'you are doing, as the heuristics used to detect the situation are\n' 'you are doing, as the heuristics used to detect the situation are\n'
'not perfect. The commit queue will not block on this warning.') 'not perfect. The commit queue will not block on this warning,\n'
'however the android-binary-size trybot will block if the method\n'
'exists in the release apk.')
_INCLUDE_ORDER_WARNING = ( _INCLUDE_ORDER_WARNING = (
......
...@@ -158,6 +158,14 @@ def _CreateUncompressedPakSizeDeltas(symbols): ...@@ -158,6 +158,14 @@ def _CreateUncompressedPakSizeDeltas(symbols):
] ]
def _CreateTestingSymbolssDeltas(symbols):
testing_symbols = symbols.WhereNameMatches('ForTest').WhereDiffStatusIs(
models.DIFF_STATUS_ADDED)
lines = list(describe.GenerateLines(testing_symbols, summarize=False))
return lines, _SizeDelta('Added symbols named "ForTest"', 'symbols', 0,
len(testing_symbols), None)
def _FormatSign(number): def _FormatSign(number):
if number > 0: if number > 0:
return '+{}'.format(number) return '+{}'.format(number)
...@@ -214,6 +222,12 @@ def main(): ...@@ -214,6 +222,12 @@ def main():
_CreateMutableConstantsDelta(changed_symbols)) _CreateMutableConstantsDelta(changed_symbols))
size_deltas.add(mutable_constants_delta) size_deltas.add(mutable_constants_delta)
# Look for symbols with 'ForTesting' in their name.
logging.info('Checking for symbols named "ForTest"')
testing_symbols_lines, test_symbols_delta = (
_CreateTestingSymbolssDeltas(changed_symbols))
size_deltas.add(test_symbols_delta)
# Check for uncompressed .pak file entries being added to avoid unnecessary # Check for uncompressed .pak file entries being added to avoid unnecessary
# bloat. # bloat.
logging.info('Checking pak symbols') logging.info('Checking pak symbols')
...@@ -272,6 +286,10 @@ PASSING: ...@@ -272,6 +286,10 @@ PASSING:
'name': '>>> Mutable Constants Diff <<<', 'name': '>>> Mutable Constants Diff <<<',
'lines': mutable_constants_lines, 'lines': mutable_constants_lines,
}, },
{
'name': '>>> "ForTest" Symbols Diff <<<',
'lines': testing_symbols_lines,
},
{ {
'name': '>>> Dex Method Diff <<<', 'name': '>>> Dex Method Diff <<<',
'lines': dex_delta_lines, 'lines': dex_delta_lines,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment