Changeset 251
- Timestamp:
- Tue Apr 18 00:08:34 2006
- Files:
-
- trunk/scripts/xix-coverage.py (modified) (diff)
- trunk/xix/utils/cover.py (modified) (diff)
- trunk/xix/data/coverage.xsl (modified) (diff)
- trunk/xix/data/report.xsl (added)
- trunk/xix/data/coverage.css (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/scripts/xix-coverage.py
r249 r251 65 65 fd.close() 66 66 67 def generateXML(reportdir, source): 67 def generateXML(reportdir, source, annotationXSLT=None): 67 67 print 'Generated coverage annotations' 68 68 parser = AnnotationParser() … … 80 80 fd = open(pj(reportdir, xml_fname), 'w') 81 81 xml.write(fd) 82 xslt = ET.parse(StringIO(_XSLT)) 82 if not annotationXSLT: 83 xslt = ET.parse(StringIO(_XSLT)) 84 else: 85 xslt = ET.parse(open(annotationXSLT)) 83 86 transform = ET.XSLT(xslt) 84 87 html = transform(xml, modname="'%s'" % srcname) … … 100 103 <xsl:for-each select="//module"> 101 104 <tr> 102 <td> 105 <td class="report-column"> 102 105 <a> 103 106 <xsl:attribute name="href"> … … 108 111 </a> 109 112 </td> 110 <td><xsl:value-of select="@statements"/></td> 111 <td><xsl:value-of select="@executed"/></td> 112 <td><xsl:value-of select="@coverage"/></td> 113 <td class="report-column"><xsl:value-of select="@statements"/></td> 114 <td class="report-column"><xsl:value-of select="@executed"/></td> 115 <td class="report-column"><xsl:value-of select="@coverage"/></td> 113 116 </tr> 114 117 </xsl:for-each> … … 116 119 </body></html> 117 120 </xsl:template> 118 119 121 </xsl:stylesheet>''' 120 122 121 def generateIndex(reportdir, source): 123 def generateIndex(reportdir, source, reportXSLT=None): 121 123 report = CoverageReportParser().parse(open('.report')) 122 124 xml = reportToXML(report, tree=True) 123 xslt = ET.parse(StringIO(_REPORT_XSLT)) 125 if not reportXSLT: 126 xslt = ET.parse(StringIO(_REPORT_XSLT)) 127 else: 128 xslt = ET.parse(open(reportXSLT)) 124 129 transform = ET.XSLT(xslt) 125 130 html = transform(xml, packagename="'%s'" % source) … … 128 133 html.write(fd) 129 134 fd.close() 130 135 130 135 def main(opts): 131 136 if not os.path.exists('coverage.py'): … … 139 144 print getoutput('python coverage.py -x %s' % opts.command) 140 145 annotate(opts.source) 141 linkmap = generateXML(reportdir, opts.source) 142 generateIndex(reportdir, opts.source) 146 generateXML(reportdir, opts.source, opts.annotation_xslt) 147 generateIndex(reportdir, opts.source, opts.report_xslt) 148 for asset in options.html_assets: 149 copy2(asset, reportdir) 143 150 print 'Report complete. See ' + pj(reportdir, 'index.html') 144 151 … … 153 160 parser.add_option('-c', action='store_true', dest='copy_compiled', 154 161 help='copy over *.pyc and *.pyo files from source.') 155 parser.add_option('-r','--report-directory', dest='report_dir', default=' docs/coverage',162 parser.add_option('-r','--report-directory', dest='report_dir', default='reports/coverage', 155 162 help='target directory for coverage reports.') 156 163 parser.add_option('-x', '--exclude-dirs', dest='exclude_dirs', default='.svn', … … 159 166 parser.add_option('-t', '--test-runner', dest='command', default='runtests.py', 160 167 help='test runner module and arguments') 168 parser.add_option('-a', '--annotation-xslt', dest='annotation_xslt', 169 help='xslt source file for generating module coverage annotation html') 170 parser.add_option('-m', '--report-xslt', dest='report_xslt', 171 help='xslt source file for generating index.html') 172 parser.add_option('-z', '--html-assets', dest='html_assets', 173 help='comma-separated list of css, image files etc. to copy to report directory') 161 174 options, args = parser.parse_args() 162 175 options.depends = options.depends.split(',') 163 176 options.exclude_dirs = options.exclude_dirs.split(',') 177 if options.report_xslt: 178 options.report_xslt = os.path.abspath(options.report_xslt) 179 if options.annotation_xslt: 180 options.annotation_xslt = os.path.abspath(options.annotation_xslt) 181 if options.html_assets: 182 options.html_assets = [ os.path.abspath(a) for a in options.html_assets.split(',') ] 164 183 main(options) 165 184 -
trunk/xix/utils/cover.py
r249 r251 158 158 <xsl:param name="modname"/> 159 159 <xsl:template match="/"> 160 <xsl:message>modname is <xsl:value-of select="$modname"/></xsl:message>161 160 <html><head><title>Coverage Results for <xsl:value-of select="$modname"/></title> 162 161 <link rel="stylesheet" type="text/css" href="coverage.css"/></head> … … 164 163 <h2>Coverage Results for <xsl:value-of select="$modname"/></h2> 165 164 <div class="annotated-source-code"> 165 <table width="100%"> 166 166 <xsl:for-each select="/coverageAnnotation/line"> 167 167 <xsl:variable name="lineno" select="position()"/> 168 168 <xsl:choose> 169 169 <xsl:when test="@executable='false'"> 170 <div class="annotation-line non-exec"> 171 <span class="lineno"><xsl:value-of select="$lineno"/></span> 172 <pre><xsl:value-of select="."/></pre></div> 170 <!--<div class="annotation-line non-exec">--> 171 <tr class="annotation-line non-exec"> 172 <td class="non-exec"><xsl:value-of select="$lineno"/></td> 173 <td><pre><xsl:value-of select="."/></pre></td></tr> 173 174 </xsl:when> 174 175 <xsl:when test="@executable='true' and @covered='true'"> 175 <div class="annotation-line executable covered"> 176 <span class="lineno"><xsl:value-of select="$lineno"/></span> 177 <pre><xsl:value-of select="."/></pre></div> 176 <tr class="annotation-line executable covered"> 177 <td class="covered"><xsl:value-of select="$lineno"/></td> 178 <td><pre><xsl:value-of select="."/></pre></td></tr> 178 179 </xsl:when> 179 180 <xsl:otherwise> 180 <div class="annotation-line executable uncovered"> 181 <span class="lineno"><xsl:value-of select="$lineno"/></span> 182 <pre><xsl:value-of select="."/></pre></div> 181 <tr class="annotation-line executable uncovered"> 182 <td class="uncovered"><xsl:value-of select="$lineno"/></td> 183 <td><pre><xsl:value-of select="."/></pre></td></tr> 183 184 </xsl:otherwise> 184 185 </xsl:choose> 185 186 </xsl:for-each> 187 </table> 186 188 </div></body></html> 187 189 </xsl:template> -
trunk/xix/data/coverage.xsl
r249 r251 9 9 <h2>Coverage Results for <xsl:value-of select="$modname"/></h2> 10 10 <div class="annotated-source-code"> 11 <table width="100%"> 11 12 <xsl:for-each select="/coverageAnnotation/line"> 12 13 <xsl:variable name="lineno" select="position()"/> 13 14 <xsl:choose> 14 15 <xsl:when test="@executable='false'"> 15 <div class="annotation-line non-exec"> 16 <span class="lineno"><xsl:value-of select="$lineno"/></span> 17 <pre><xsl:value-of select="."/></pre></div> 16 <!--<div class="annotation-line non-exec">--> 17 <tr class="annotation-line non-exec"> 18 <td class="non-exec"><xsl:value-of select="$lineno"/></td> 19 <td><pre><xsl:value-of select="."/></pre></td></tr> 18 20 </xsl:when> 19 21 <xsl:when test="@executable='true' and @covered='true'"> 20 <div class="annotation-line executable covered"> 21 <span class="lineno"><xsl:value-of select="$lineno"/></span> 22 <pre><xsl:value-of select="."/></pre></div> 22 <tr class="annotation-line executable covered"> 23 <td class="covered"><xsl:value-of select="$lineno"/></td> 24 <td><pre><xsl:value-of select="."/></pre></td></tr> 23 25 </xsl:when> 24 26 <xsl:otherwise> 25 <div class="annotation-line executable uncovered"> 26 <span class="lineno"><xsl:value-of select="$lineno"/></span> 27 <pre><xsl:value-of select="."/></pre></div> 27 <tr class="annotation-line executable uncovered"> 28 <td class="uncovered"><xsl:value-of select="$lineno"/></td> 29 <td><pre><xsl:value-of select="."/></pre></td></tr> 28 30 </xsl:otherwise> 29 31 </xsl:choose> 30 32 </xsl:for-each> 33 </table> 31 34 </div></body></html> 32 35 </xsl:template> -
trunk/xix/data/coverage.css
r249 r251 1 body { 2 margin: 0px; 3 } 4 5 h2 { 6 padding: 3px; 7 margin: 0px; 8 background-color: #ddd; 9 border-bottom: 2px solid; 10 } 11 12 th { 13 text-align: left; 14 padding-right: 28px; 15 } 16 17 .report-column { 18 border-bottom: 1px dashed; 19 padding-right: 28px; 20 } 21 22 a { 23 text-decoration: none; 24 } 25 1 26 .annotation-line { 2 27 border-left: 8px solid #aaa; … … 6 31 .covered { 7 32 border-left: 8px solid #3e3; 33 background-color: #cfc; 8 34 } 9 35 … … 21 47 } 22 48 49 .non-exec { 50 border-left: 8px solid #aaa; 51 background-color: #eee; 52 } 53 23 54 .lineno { 24 55 margin-right: 5px;
