Changeset 293
- Timestamp:
- Mon Sep 4 10:29:32 2006
- Files:
-
- trunk/scripts/xix-coverage.py (modified) (diff)
- trunk/xix/utils/decor.py (modified) (diff)
- trunk/xix/utils/cover.py (modified) (diff)
- trunk/xix/data/coverage.css (modified) (diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
trunk/scripts/xix-coverage.py
r263 r293 123 123 </tr> 124 124 </xsl:for-each> 125 <xsl:for-each select="//summary"> 126 <tr class="summary"> 127 <td class="report-column">TOTAL 128 </td> 129 <td class="report-column"><xsl:value-of select="@statements"/></td> 130 <td class="report-column"><xsl:value-of select="@executed"/></td> 131 <td class="report-column"><xsl:value-of select="@coverage"/></td> 132 </tr> 133 </xsl:for-each> 125 134 </table> 126 135 <div id="colophon">Report generated on <xsl:value-of select="$utctime"/> GMT<br/> … … 177 186 parser.add_option('-c', action='store_true', dest='copy_compiled', 178 187 help='copy over *.pyc and *.pyo files from source.') 179 parser.add_option('-r','--report-directory', dest='report_dir', default='reports/coverage', 188 parser.add_option('-r','--report-directory', dest='report_dir', default='build/reports/coverage', 179 188 help='target directory for coverage reports.') 180 189 parser.add_option('-x', '--exclude-dirs', dest='exclude_dirs', default='.svn', -
trunk/xix/utils/decor.py
r212 r293 44 44 return _wrapup(wrapper, func) 45 45 46 def noraise(out=None): 47 """Do not raise any exceptions ... or event report [evil laugh]. Of course 48 you should likely use only in test code ... 49 50 Example usage: 51 52 >>> @noraise() 53 ... def stupid(a, b, c=4): 54 ... print a + b + c 55 ... raise Exception 56 ... 57 >>> stupid(1, 2, c=5) 58 8 59 60 >>> import sys 61 >>> @noraise(out=sys.stdout) 62 ... def err(): 63 ... raise Exception, 'bummer' 64 ... 65 >>> err() 66 bummer 67 68 """ 69 def decor(func): 70 def wrapper(*pargs, **kwargs): 71 try: 72 return func(*pargs, **kwargs) 73 except Exception, e: 74 if out: 75 print >> out, e 76 return 77 return _wrapup(wrapper, func) 78 return decor 79 46 80 -
trunk/xix/utils/cover.py
r251 r293 91 91 class CoverageReport(UserList): 92 92 package_name = None 93 summary = None 93 94 94 95 class CoverageReportEntry: … … 108 109 fd = open(input) 109 110 report = CoverageReport() 110 for line in fd.readlines()[2: -2]:111 for line in fd.readlines()[2:]: 110 111 tokens = line.split() 111 modname, stmts, execd, coverage = tokens[:4] 112 try: 113 modname, stmts, execd, coverage = tokens[:4] 114 perc = coverage[:-1] 115 _stmts, _execd = int(stmts), int(execd) 116 except Exception, e: 117 continue 118 if modname == 'TOTAL': 119 report.summary = CoverageReportEntry(modname, stmts, execd, coverage, None) 120 break 112 121 modname = modname.replace(os.path.sep, '.') 113 122 missed = [ tk.replace(',','') for tk in tokens[4:] ] … … 133 142 def _reportToXML(report): 134 143 root = ET.Element('coverage-report') 144 elm = ET.SubElement(root, 'summary') 145 attr = elm.attrib 146 attr['statements'] = report.summary.statements 147 attr['executed'] = report.summary.executed 148 attr['coverage'] = report.summary.coverage 135 149 for entry in report: 136 150 elm = ET.SubElement(root, 'module') … … 138 152 attr['name'] = entry.modname 139 153 attr['statements'] = entry.statements 140 attr['executed'] = entry.executed141 154 attr['coverage'] = entry.coverage 155 attr['executed'] = entry.executed 142 156 melm = ET.SubElement(elm, 'missing-ranges') 143 157 for missed in entry.missing: -
trunk/xix/data/coverage.css
r263 r293 20 20 } 21 21 22 .summary { 23 background-color: #eed; 24 border-bottom: 0px; 25 } 26 22 27 a { 23 28 text-decoration: none; … … 26 31 .annotation-line { 27 32 font-style: italic; 28 font-weight: normal; 29 font-family: hevetica,sans-serif,arial,mono; 33 font-weight: 700; 34 font-family: mono,arial; 30 35 border-left: 8px solid #aaa; 31 36 padding-left: 5px;
