Ticket #692: phptools.py.diff
| File phptools.py.diff, 2.1 KB (added by Dariusz Czech <dczech@…>, 23 months ago) |
|---|
-
phptools.py
114 114 coverage.append(class_coverage) 115 115 116 116 def _process_phpunit_coverage(ctxt, element, coverage): 117 def _process_line_data(data): 118 line_hits = [] 119 line_nums = data.keys() 120 line_nums.sort() 121 for num in line_nums: 122 line_hits.extend((num - len(line_hits) - 1) * ['-']) 123 line_hits.append(str(data[num])) 124 return ' '.join(line_hits) 117 125 for cls in element._node.getElementsByTagName('class'): 118 126 sourcefile = cls.parentNode.getAttribute('name') 119 127 if not os.path.isabs(sourcefile): 120 128 sourcefile = os.path.join(ctxt.basedir, sourcefile) 121 129 if sourcefile.startswith(ctxt.basedir): 130 line_data = {} 122 131 loc, ncloc = 0, 0.0 123 132 for line in cls.parentNode.getElementsByTagName('line'): 133 num = int(line.getAttribute('num')) 134 cnt = int(line.getAttribute('count')) 135 line_data[num] = cnt 124 136 if str(line.getAttribute('type')) == 'stmt': 125 137 loc += 1 126 if int(line.getAttribute('count'))== 0:138 if cnt == 0: 127 139 ncloc += 1 128 140 if loc > 0: 129 141 percentage = 100 - (ncloc / loc * 100) 130 142 else: 131 143 percentage = 100 132 144 145 146 133 147 if sourcefile.startswith(ctxt.basedir): 134 148 sourcefile = sourcefile[len(ctxt.basedir) + 1:] 135 149 class_coverage = xmlio.Element('coverage', 136 150 name=cls.getAttribute('name'), 137 151 lines=int(loc), 152 line_hits=_process_line_data(line_data), 138 153 percentage=int(percentage), 139 154 file=sourcefile.replace(os.sep, '/')) 140 155 coverage.append(class_coverage)
