From efbe1df1992ebe791415ad65d0772153b8152b51 Mon Sep 17 00:00:00 2001 From: Abhishek Arya <inferno@chromium.org> Date: Mon, 14 May 2018 20:19:48 +0000 Subject: [PATCH] Coverage: Don't show totals entry for component view. A path can belong to multiple components, so totals entry shows incorrect value. R=mmoroz@chromium.org,liaoyuke@chromium.org Bug: 842760 Change-Id: Ibbae86ed31a9d330ed02a6e7a24a5211634b2fc5 Reviewed-on: https://chromium-review.googlesource.com/1058167 Reviewed-by: Max Moroz <mmoroz@chromium.org> Commit-Queue: Abhishek Arya <inferno@chromium.org> Cr-Commit-Position: refs/heads/master@{#558437} --- tools/code_coverage/coverage.py | 10 +++---- tools/code_coverage/html_templates/table.html | 26 ++++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/code_coverage/coverage.py b/tools/code_coverage/coverage.py index 4f73bd27e927e..7f45542a1911b 100755 --- a/tools/code_coverage/coverage.py +++ b/tools/code_coverage/coverage.py @@ -742,17 +742,15 @@ def _GenerateComponentViewHtmlIndexFile(per_component_coverage_summary, component_view_index_file_path) html_generator = _CoverageReportHtmlGenerator(component_view_index_file_path, 'Component') - totals_coverage_summary = _CoverageSummary() - for component in per_component_coverage_summary: - totals_coverage_summary.AddSummary( - per_component_coverage_summary[component]) - html_generator.AddLinkToAnotherReport( _GetCoverageHtmlReportPathForComponent(component), component, per_component_coverage_summary[component]) - html_generator.CreateTotalsEntry(totals_coverage_summary) + # Do not create a totals row for the component view as the value is incorrect + # due to failure to account for UNKNOWN component and some paths belonging to + # multiple components. + html_generator.WriteHtmlCoverageReport(no_file_view) logging.debug('Finished generating component view html index file.') diff --git a/tools/code_coverage/html_templates/table.html b/tools/code_coverage/html_templates/table.html index 28f88952614ab..63cca09ead963 100644 --- a/tools/code_coverage/html_templates/table.html +++ b/tools/code_coverage/html_templates/table.html @@ -31,16 +31,18 @@ </tr> {% endfor %} </tbody> - <tfoot> - <tr class="light-row-bold"> - <td> - <pre>Totals</pre> - </td> - {% for feature in ("lines", "functions", "regions") %} - <td class='column-entry-{{ total_entry[feature]["color_class"] }}'> - <pre>{{ total_entry[feature]["percentage"] }}% ({{ total_entry[feature]["covered"] }}/{{ total_entry[feature]["total"] }})</pre> - </td> - {% endfor %} - </tr> - </tfoot> + {% if total_entry %} + <tfoot> + <tr class="light-row-bold"> + <td> + <pre>Totals</pre> + </td> + {% for feature in ("lines", "functions", "regions") %} + <td class='column-entry-{{ total_entry[feature]["color_class"] }}'> + <pre>{{ total_entry[feature]["percentage"] }}% ({{ total_entry[feature]["covered"] }}/{{ total_entry[feature]["total"] }})</pre> + </td> + {% endfor %} + </tr> + </tfoot> + {% endif %} </table> \ No newline at end of file