Edgewall Software

Ticket #692: phptools.py.diff

File phptools.py.diff, 2.1 KB (added by Dariusz Czech <dczech@…>, 23 months ago)
  • phptools.py

     
    114114            coverage.append(class_coverage) 
    115115 
    116116    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)  
    117125        for cls in element._node.getElementsByTagName('class'): 
    118126            sourcefile = cls.parentNode.getAttribute('name') 
    119127            if not os.path.isabs(sourcefile): 
    120128                sourcefile = os.path.join(ctxt.basedir, sourcefile) 
    121129            if sourcefile.startswith(ctxt.basedir): 
     130                line_data = {} 
    122131                loc, ncloc = 0, 0.0 
    123132                for line in cls.parentNode.getElementsByTagName('line'): 
     133                    num = int(line.getAttribute('num')) 
     134                    cnt = int(line.getAttribute('count')) 
     135                    line_data[num] = cnt 
    124136                    if str(line.getAttribute('type')) == 'stmt': 
    125137                        loc += 1 
    126                         if int(line.getAttribute('count')) == 0: 
     138                        if cnt == 0: 
    127139                            ncloc += 1 
    128140                if loc > 0: 
    129141                    percentage = 100 - (ncloc / loc * 100) 
    130142                else: 
    131143                    percentage = 100 
    132144 
     145                 
     146 
    133147                if sourcefile.startswith(ctxt.basedir): 
    134148                    sourcefile = sourcefile[len(ctxt.basedir) + 1:] 
    135149                class_coverage = xmlio.Element('coverage', 
    136150                                    name=cls.getAttribute('name'), 
    137151                                    lines=int(loc), 
     152                                    line_hits=_process_line_data(line_data), 
    138153                                    percentage=int(percentage), 
    139154                                    file=sourcefile.replace(os.sep, '/')) 
    140155                coverage.append(class_coverage)