[Coverage] Improve format of generated code coverage reports.
This CL responds to: https://reviews.llvm.org/rL323892
Specifically, this CL makes the following changes:
1. Coverage numbers are aligned to the left and padded with spaces.
2. Table headings now use bold text.
3. Name of the total row is changed from "TOTALS" to "Totals".
Here is a screenshot of an example report:
https://drive.google.com/open?id=1oNN_WVU7g1o2ORTkQh4uhNEVCkwqf_c-
Bug: 800016
Change-Id: I1ff22e58e11bb804e1c96513bb259fa1756501fa
Reviewed-on: https://chromium-review.googlesource.com/915186
Reviewed-by: Abhishek Arya <[email protected]>
Commit-Queue: Yuke Liao <[email protected]>
Cr-Commit-Position: refs/heads/master@{#536488}
diff --git a/tools/code_coverage/coverage.py b/tools/code_coverage/coverage.py
index ecd9fb0..5d003695 100755
--- a/tools/code_coverage/coverage.py
+++ b/tools/code_coverage/coverage.py
@@ -205,7 +205,7 @@
self._table_entries.append(table_entry)
def CreateTotalsEntry(self, summary):
- """Creates an entry corresponds to the 'TOTALS' row in the html report."""
+ """Creates an entry corresponds to the 'Totals' row in the html report."""
self._total_entry = self._CreateTableEntryFromCoverageSummary(summary)
def _CreateTableEntryFromCoverageSummary(self,
@@ -217,7 +217,7 @@
assert (href is None and name is None and is_dir is None) or (
href is not None and name is not None and is_dir is not None), (
'The only scenario when href or name or is_dir can be None is when '
- 'creating an entry for the TOTALS row, and in that case, all three '
+ 'creating an entry for the Totals row, and in that case, all three '
'attributes must be None.')
entry = {}
@@ -233,13 +233,14 @@
if summary_dict[feature]['total'] == 0:
percentage = 0.0
else:
- percentage = round((float(summary_dict[feature]['covered']
- ) / summary_dict[feature]['total']) * 100, 2)
+ percentage = float(summary_dict[feature]['covered']) / summary_dict[
+ feature]['total'] * 100
+
color_class = self._GetColorClass(percentage)
entry[feature] = {
'total': summary_dict[feature]['total'],
'covered': summary_dict[feature]['covered'],
- 'percentage': percentage,
+ 'percentage': '{:6.2f}'.format(percentage),
'color_class': color_class
}