reports/Builder__CoverageReport.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 290 c5fdcba3c682
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
     5
Report subclass:#CoverageReport
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
     6
	instanceVariableNames:'instrumentedMethods'
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
     9
	category:'Builder-Reports'
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    13
!CoverageReport methodsFor:'accessing-defaults'!
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    14
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    15
defaultFileSuffix
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    16
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    17
    "Return a default filename suffix. Note that format suffix will be 
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    18
     appended too if not file is explicitely specified"
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    19
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    20
    ^'Coverage'
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    22
    "Created: / 25-06-2013 / 01:12:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    23
!
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    24
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    25
defaultFormat
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    26
    "raise an error: must be redefined in concrete subclass(es)"
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    27
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    28
    ^ Builder::CoverageReportFormat::Cobertura new
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    29
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    30
    "Modified: / 25-06-2013 / 01:31:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    33
defaultName
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    34
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    35
    packages isNil ifTrue:[
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    36
        ^'someClasses'.
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    37
    ].
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    39
    ^String streamContents:[:s|
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    40
        packages do:[:packageOrClass|
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    41
            s nextPutAll: packageOrClass printString 
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    42
        ] separatedBy:[
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    43
            s nextPut:$,;space
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    44
        ]
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    45
    ]
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    47
    "Created: / 25-06-2013 / 01:29:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    48
! !
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    49
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    50
!CoverageReport methodsFor:'initialization'!
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    51
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    52
initialize
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    53
    instrumentedMethods := Set new.
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    54
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    55
    "Created: / 25-06-2013 / 01:40:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    56
    "Modified: / 25-06-2013 / 13:21:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    59
setupForClasses:classes
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    60
    "raise an error: must be redefined in concrete subclass(es)"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    62
    classes do:[:each | self instrumentClass: each].
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    63
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    64
    "Modified: / 25-06-2013 / 16:22:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    67
setupForPackages:pkgs
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    68
    "raise an error: must be redefined in concrete subclass(es)"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    70
    pkgs do:[:each | self instrumentPackage: each ].
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    71
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    72
    "Modified: / 25-06-2013 / 16:22:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
! !
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    75
!CoverageReport methodsFor:'instrumentation'!
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    77
instrumentClass:class
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    78
    class instAndClassMethods do:[:method|
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    79
        self instrumentMethod: method 
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    80
    ]
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    82
    "Created: / 25-06-2013 / 01:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    85
instrumentMethod:method
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    86
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    87
    | class selector |
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    88
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    89
    class := method mclass.
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    90
    selector := method selector.
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    91
    (self excludedFromCoverage: method) ifFalse:[
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    92
        method isInstrumented ifFalse:[
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    93
            InstrumentingCompiler compileMethod: method.
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    94
        ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    95
        instrumentedMethods add: (class compiledMethodAt: selector)
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    96
    ]
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    97
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
    98
    "Created: / 25-06-2013 / 01:44:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
    99
    "Modified: / 28-06-2013 / 02:45:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   102
instrumentPackage:pkg
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   103
    Smalltalk allMethodsDo:[:method|
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   104
        method package asSymbol == pkg asSymbol ifTrue:[
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   105
            self instrumentMethod: method.
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   106
        ]
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   107
    ]
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   109
    "Created: / 25-06-2013 / 01:42:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   110
    "Modified: / 25-06-2013 / 17:51:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
! !
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   113
!CoverageReport methodsFor:'queries'!
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   114
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   115
excludedFromCoverage: aMethod
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   116
    "Returns true, if given method should be excluded from
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   117
     coverage report.
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   118
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   119
     Here, certain 'metadata' method like documentation, copyright,
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   120
     version methods, printOn: and so on are exluded. Also, testcases
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   121
     and test resources are ommited"
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   122
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   123
    | mclass mselector tree pkgdef |
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   124
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   125
    mclass := aMethod mclass.
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   126
    mselector := aMethod selector.
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   127
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   128
    aMethod hasPrimitiveCode ifTrue:[ ^ true ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   129
    (mclass inheritsFrom: TestCase) ifTrue:[ ^ true ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   130
    (mclass inheritsFrom: TestResource) ifTrue:[ ^ true ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   131
    (mclass inheritsFrom: ProjectDefinition) ifTrue:[ ^ true ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   132
    mclass isMetaclass ifTrue:[
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   133
        (#(
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   134
                copyright 
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   135
                documentation
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   136
        ) includes: mselector) ifTrue:[ ^ true ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   137
        (AbstractSourceCodeManager isVersionMethodSelector: mselector) ifTrue:[ ^ true ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   138
    ] ifFalse:[
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   139
        (#(
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   140
            printString printOn: 
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   141
            inspectorExtraAttributes inspectorClass
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   142
        ) includes: mselector) ifTrue:[ ^ true ].    
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   143
    ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   144
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   145
    tree := (Parser parseMethod: aMethod source in: mclass) tree.
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   146
    tree isNil ifTrue:[ ^ true ]. "/ empty method?
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   147
    (tree isStatement and:[tree isReturnNode not and:[tree nextStatement isNil]]) ifTrue:[
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   148
        tree := tree expression.
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   149
    ].
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   150
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   151
    "/ Exclude all getters/return constants...
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   152
    (aMethod numArgs == 0 
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   153
        and:[tree isReturnNode 
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   154
        and:[tree expression isVariable or:[tree expression isConstant]]]) ifTrue:[ ^ true ].
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   155
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   156
    "/ Exclude all setters
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   157
    (aMethod numArgs == 1 
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   158
        and:[tree isAssignment 
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   159
        and:[(tree variable isInstanceVariable or:[tree variable isClassVariable])
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   160
        and:[tree expression isVariable
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   161
        and:[tree expression isMethodArg]]]]) ifTrue:[ ^ true ].
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   162
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   163
    pkgdef := ProjectDefinition definitionClassForPackage: aMethod package.
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   164
    pkgdef notNil ifTrue:[
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   165
        ^ pkgdef excludedFromCoverage:aMethod.
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   166
    ].
290
c5fdcba3c682 class: Builder::CoverageReport
Stefan Vogel <sv@exept.de>
parents: 187
diff changeset
   167
    ^ false
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   168
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   169
    "Created: / 28-06-2013 / 02:20:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
187
ee2471c56070 class: Builder::CoverageReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 185
diff changeset
   170
    "Modified (comment): / 28-06-2013 / 11:31:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
185
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   171
! !
f1415a086e05 Improvements in coverage - exclude accessors and metadata methods.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 166
diff changeset
   172
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
!CoverageReport methodsFor:'running'!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   175
runReport
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   176
    "Actually run the report. What to do (what classes/packages to check)
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   177
     must be stored instance variables"
148
50cf14e8d665 class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 68
diff changeset
   178
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   179
    format write: instrumentedMethods.
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
166
5bf6af786b93 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 148
diff changeset
   181
    "Modified: / 25-06-2013 / 13:13:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
! !
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
!CoverageReport class methodsFor:'documentation'!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
version
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    ^ '$Header$'
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
version_CVS
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
    ^ '$Header$'
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
!
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
version_SVN
148
50cf14e8d665 class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 68
diff changeset
   195
    ^ '$Id$'
68
898a31eab2db initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
! !
148
50cf14e8d665 class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 68
diff changeset
   197