Commit d3d51f85 authored by Yuke Liao's avatar Yuke Liao Committed by Commit Bot

[Coverage] Fix a bug in code coverage tool.

The original intention of the following statement is that: if
|coverage| is not None, do something, else do something else.

'{}%'.format(int(coverage * 100)) if coverage else None

However, the code doesn't behave as expected when |coverage| is 0 that
|coverage| is not None, but if coverage returns False.

This CL fixes this bug.

Bug: 
Change-Id: I8d9c667996d10d24f3841fb65b09348aeb85e3ca
Reviewed-on: https://chromium-review.googlesource.com/673141Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Yuke Liao <liaoyuke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#502953}
parent 56162f2a
......@@ -291,12 +291,13 @@ def _PrintLineCoverageStats(total_lines, executed_lines):
"""
missed_lines = total_lines - executed_lines
coverage = float(executed_lines) / total_lines if total_lines > 0 else None
percentage_coverage = '{}%'.format(int(coverage * 100)) if coverage else None
percentage_coverage = ('{}%'.format(int(coverage * 100))
if coverage is not None else 'NA')
output = ('Total Lines: {}\tExecuted Lines: {}\tMissed Lines: {}\t'
'Coverage: {}\n')
print output.format(total_lines, executed_lines, missed_lines,
percentage_coverage or 'NA')
percentage_coverage)
def _BuildTargetWithCoverageConfiguration(target, jobs_count):
......
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