reports/Builder__CoverageReportFormat.st
changeset 183 4e6fc1b6c282
parent 182 556ad4c2c381
child 186 b53f4cc947e1
equal deleted inserted replaced
182:556ad4c2c381 183:4e6fc1b6c282
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'Builder-Reports-Formats'
     9 	category:'Builder-Reports-Formats'
    10 !
    10 !
    11 
    11 
    12 CoverageReportFormat subclass:#Cobertura
    12 CoverageReportFormat subclass:#Cobertura
    13 	instanceVariableNames:'currentPackage currentClass currentMethod infos'
    13 	instanceVariableNames:'currentPackage currentClass currentClassLinesBuffer currentMethod
       
    14 		infos'
    14 	classVariableNames:''
    15 	classVariableNames:''
    15 	poolDictionaries:''
    16 	poolDictionaries:''
    16 	privateIn:CoverageReportFormat
    17 	privateIn:CoverageReportFormat
    17 !
    18 !
    18 
    19 
    78     | packageMap |
    79     | packageMap |
    79 
    80 
    80     packageMap := Dictionary new.
    81     packageMap := Dictionary new.
    81     infos := Dictionary new.
    82     infos := Dictionary new.
    82     instrumentedMethods do:[:method|
    83     instrumentedMethods do:[:method|
    83         | classMap methodMap |
    84         | classMap methodSet |
    84         classMap := packageMap at: method package ifAbsentPut: [ Dictionary new ].
    85         classMap := packageMap at: method package ifAbsentPut: [ Dictionary new ].
    85         methodMap := classMap at: method mclass ifAbsentPut: [ Dictionary new ].
    86         methodSet := classMap at: method mclass ifAbsentPut: [ Set new ].
    86         methodMap at: method selector put: method.
    87         methodSet add: method.
    87     ].
    88     ].
    88 
    89 
    89     packageMap keys asSortedCollection do:[:package|
    90     packageMap keys asSortedCollection do:[:package|
    90         | classMap |            
    91         | classMap |            
    91 
    92 
    92         self writePackage: package with:[            
    93         self writePackage: package with:[            
    93             ((classMap := packageMap at: package) keys asSortedCollection:[:a :b| a name < b name ]) do:[:class|
    94             ((classMap := packageMap at: package) keys asSortedCollection:[:a :b| a name < b name ]) do:[:class|
    94                 | methodMap |
    95                 | methodSet |
    95                 self writeClass: class with:[
    96                 self writeClass: class with:[
    96                     (methodMap := classMap at: class) keys asSortedCollection do:[:selector|
    97                     | methodSetOrdered info |
    97                         | method |
    98 
    98 
    99                     info := infos at: class ifAbsentPut:[ReportSourceInfo for: class].
    99                         method := methodMap at: selector.
   100                     methodSetOrdered := (classMap at: class) asSortedCollection:[:a :b | (info offsetOfMethod: a) < (info offsetOfMethod: b)].
       
   101                     methodSetOrdered do:[:method|
   100                         self writeMethod: method.
   102                         self writeMethod: method.
   101                     ]                    
   103                     ]                    
   102                 ]
   104                 ]
   103             ]
   105             ]
   104         ]
   106         ]
   105     ]
   107     ]
   106 
   108 
   107     "Created: / 25-06-2013 / 13:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   109     "Created: / 25-06-2013 / 13:17:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   110     "Modified: / 27-06-2013 / 11:56:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   108 !
   111 !
   109 
   112 
   110 writeClass: class with: content
   113 writeClass: class with: content
   111 
   114 
   112     | className classFileName classPathName |
   115     | className classFileName classPathName |
   122                         , Filename separator , classFileName.
   125                         , Filename separator , classFileName.
   123 
   126 
   124     stream nextPutAll:'        <class name="'; nextPutAll: className; nextPutAll: '" filename="'; nextPutAll: classPathName; nextPutLine:'" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
   127     stream nextPutAll:'        <class name="'; nextPutAll: className; nextPutAll: '" filename="'; nextPutAll: classPathName; nextPutLine:'" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
   125     stream nextPutLine:'          <methods>'.
   128     stream nextPutLine:'          <methods>'.
   126     currentClass := class.
   129     currentClass := class.
       
   130     currentClassLinesBuffer := String new writeStream.
   127     content value.               
   131     content value.               
   128     currentClass := nil.
   132     currentClass := nil.
   129     stream nextPutLine:'          </methods>'.
   133     stream nextPutLine:'          </methods>'.
       
   134     stream nextPutLine:'          <lines>'.
       
   135     stream nextPutAll: currentClassLinesBuffer contents.
       
   136     stream nextPutLine:'          </lines>'.
       
   137     currentClassLinesBuffer := nil.
   130     stream nextPutLine:'        </class>'
   138     stream nextPutLine:'        </class>'
   131 
   139 
   132     "Created: / 25-06-2013 / 12:29:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   140     "Created: / 25-06-2013 / 12:29:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   133     "Modified: / 26-06-2013 / 17:46:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   141     "Modified: / 27-06-2013 / 00:05:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   134 !
   142 !
   135 
   143 
   136 writeFooter
   144 writeFooter
   137     stream nextPutAll:'  </packages>
   145     stream nextPutAll:'  </packages>
   138 </coverage>'
   146 </coverage>'
   157     stream nextPutLine:'  <packages>'.
   165     stream nextPutLine:'  <packages>'.
   158 
   166 
   159     "Modified: / 26-06-2013 / 17:50:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   167     "Modified: / 26-06-2013 / 17:50:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   160 !
   168 !
   161 
   169 
   162 writeLine: lineNr hits: nhits
   170 writeLine: lineNr hits: nhits on: s
   163 
   171 
   164     stream nextPut:'            <line number="'; nextPutAll: lineNr printString; nextPutAll:'" hits="'; nextPutAll: nhits printString; nextPutLine:'" branch="false" />'.
   172     s nextPutAll:'            <line number="'; nextPutAll: lineNr printString; nextPutAll:'" hits="'; nextPutAll: nhits printString; nextPutLine:'" branch="false" />'.
   165 
   173 
   166     "Created: / 25-06-2013 / 13:04:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   174     "Created: / 27-06-2013 / 00:03:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   167     "Modified: / 25-06-2013 / 14:23:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   168 !
   175 !
   169 
   176 
   170 writeMethod: method
   177 writeMethod: method
   171 
   178 
   172     | info firstCharOffset firstLineNr lastLineNr lines  |
   179     | info firstCharOffset firstLineNr lastLineNr lines  |
   173 
   180 
   174     stream nextPutAll:'        <method name="'; nextPutAll: method selector; nextPutLine: '" signature="()" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
   181     stream nextPutAll:'        <method name="'; nextPutAll: method selector; nextPutLine: '" signature="" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
   175     stream nextPutLine:'          <lines>'.
   182     stream nextPutLine:'          <lines>'.
   176     currentMethod := method.
   183     currentMethod := method.
   177 
   184 
   178     info := infos at: method mclass ifAbsentPut:[ReportSourceInfo for: method mclass].
   185     info := infos at: method mclass ifAbsentPut:[ReportSourceInfo for: method mclass].
   179     firstCharOffset := info offsetOfMethod: method.
   186     firstCharOffset := info offsetOfMethod: method.
   192             lines at: (lineNr - firstLineNr + 1) put: ((lines at: (lineNr - firstLineNr + 1)) min: eachBlockInfo count)
   199             lines at: (lineNr - firstLineNr + 1) put: ((lines at: (lineNr - firstLineNr + 1)) min: eachBlockInfo count)
   193         ]            
   200         ]            
   194     ].
   201     ].
   195 
   202 
   196     1 to: lines size do:[:i|
   203     1 to: lines size do:[:i|
   197         self writeLine: (i + firstLineNr - 1) hits: (lines at: i)
   204         self writeLine: (i + firstLineNr - 1) hits: (lines at: i) on: stream.
       
   205         self writeLine: (i + firstLineNr - 1) hits: (lines at: i) on: currentClassLinesBuffer.
   198     ].
   206     ].
   199 
   207 
   200     currentMethod := nil.
   208     currentMethod := nil.
   201     stream nextPutLine:'          </lines>'.
   209     stream nextPutLine:'          </lines>'.
   202     stream nextPutLine:'        </method>'
   210     stream nextPutLine:'        </method>'
   203 
   211 
   204     "Created: / 25-06-2013 / 13:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   212     "Created: / 25-06-2013 / 13:17:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   205     "Modified: / 25-06-2013 / 14:51:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   213     "Modified: / 27-06-2013 / 00:04:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   206 !
   214 !
   207 
   215 
   208 writeMethod: method with: content
   216 writeMethod: method with: content
   209 
   217 
   210     stream nextPutLine:'        <method name="'; nextPutAll: method selector; nextPutAll: '" signature="" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.
   218     stream nextPutLine:'        <method name="'; nextPutAll: method selector; nextPutAll: '" signature="" line-rate="1.0" branch-rate="1.0" complexity="1.0">'.