From 9266eebcd681ec38f118fe018a154acb5f1c67ae Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 22 Jul 2015 08:44:58 -0400 Subject: Add an attribute to the XML report for missed branches --- AUTHORS.txt | 1 + coverage/xmlreport.py | 4 ++++ tests/farm/html/gold_y_xml_branch/coverage.xml | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 022342c5..7db5d1c2 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -59,6 +59,7 @@ Sigve Tjora Stan Hu Stefan Behnel Steve Leonard +Steve Peak Ted Wexler Titus Brown Zooko Wilcox-O'Hearn diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index 5f16bc4f..0df449f3 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -147,6 +147,7 @@ class XmlReporter(Reporter): xclass.setAttribute("complexity", "0") branch_stats = analysis.branch_stats() + missing_branch_arcs = analysis.missing_branch_arcs() # For each statement, create an XML 'line' element. for line in sorted(analysis.statements): @@ -165,6 +166,9 @@ class XmlReporter(Reporter): "condition-coverage", "%d%% (%d/%d)" % (100*taken/total, taken, total) ) + if line in missing_branch_arcs: + annlines = ["exit" if b < 0 else str(b) for b in missing_branch_arcs[line]] + xline.setAttribute("missing-branches", ",".join(annlines)) xlines.appendChild(xline) class_lines = len(analysis.statements) diff --git a/tests/farm/html/gold_y_xml_branch/coverage.xml b/tests/farm/html/gold_y_xml_branch/coverage.xml index 9d3e37fc..63625b28 100644 --- a/tests/farm/html/gold_y_xml_branch/coverage.xml +++ b/tests/farm/html/gold_y_xml_branch/coverage.xml @@ -13,7 +13,7 @@ - + -- cgit v1.2.1