diff options
author | Stan Hu <stan.hu@aclimalabs.com> | 2014-02-03 23:33:26 -0800 |
---|---|---|
committer | Stan Hu <stan.hu@aclimalabs.com> | 2014-02-03 23:33:26 -0800 |
commit | 5f113bc7a9272c9917d3c701eb63a6b98005254f (patch) | |
tree | 0c32039f7378eab6b35e13fc49d3d04232599fbf /coverage/xmlreport.py | |
parent | 442a0ba30c5c803e649331d8c6e1e449fcc1a161 (diff) | |
download | python-coveragepy-git-5f113bc7a9272c9917d3c701eb63a6b98005254f.tar.gz |
Issue #94: Include the sources element
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") |