diff options
Diffstat (limited to 'coverage/xmlreport.py')
-rw-r--r-- | coverage/xmlreport.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index f5a4c1ba..2fb51007 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -17,6 +17,7 @@ class XmlReporter(Reporter): def __init__(self, coverage, config): super(XmlReporter, self).__init__(coverage, config) + self.source_paths = None self.packages = None self.xml_out = None self.arcs = coverage.data.has_arcs() @@ -47,16 +48,28 @@ class XmlReporter(Reporter): xcoverage.appendChild(self.xml_out.createComment( " Generated by coverage.py: %s " % __url__ )) - xpackages = self.xml_out.createElement("packages") - xcoverage.appendChild(xpackages) # Call xml_file for each file in the data. + self.source_paths = set() self.packages = {} self.report_files(self.xml_file, morfs) + xsources = self.xml_out.createElement("sources") + xcoverage.appendChild(xsources) + + # Populate the XML DOM with the source info. + for path in sorted(self.source_paths): + xsource = self.xml_out.createElement("source") + xsources.appendChild(xsource) + txt = self.xml_out.createTextNode(path) + xsource.appendChild(txt) + lnum_tot, lhits_tot = 0, 0 bnum_tot, bhits_tot = 0, 0 + xpackages = self.xml_out.createElement("packages") + xcoverage.appendChild(xpackages) + # Populate the XML DOM with the package info. for pkg_name in sorted(self.packages.keys()): pkg_data = self.packages[pkg_name] @@ -99,6 +112,7 @@ class XmlReporter(Reporter): package_name = cu.name.rpartition(".")[0] className = cu.name + path = self.source_paths.add(cu.file_locator.relative_dir.rstrip('/')) package = self.packages.setdefault(package_name, [{}, 0, 0, 0, 0]) xclass = self.xml_out.createElement("class") |