reports/Builder__TestReport.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 251 cb6ebbd8d1c0
child 303 e217bb7aacf4
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:
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
Report subclass:#TestReport
241
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
     6
	instanceVariableNames:'suite coverage instrument keepStdout'
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
     7
	classVariableNames:''
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
     8
	poolDictionaries:''
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
     9
	category:'Builder-Reports'
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
TestResult subclass:#Result
247
7387f32855da Correctly capture and report stdout.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 246
diff changeset
    13
	instanceVariableNames:'format time npassed nfailed nerror nskipped collector'
241
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    14
	classVariableNames:''
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    15
	poolDictionaries:''
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    16
	privateIn:TestReport
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
!TestReport methodsFor:'accessing'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
241
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    22
keepStdout
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    23
    ^ keepStdout
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    24
!
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    25
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    26
keepStdout:aBoolean
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    27
    keepStdout := aBoolean.
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    28
!
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
    29
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
suite
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
    ^ suite
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
    "Created: / 07-11-2011 / 09:41:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
!TestReport methodsFor:'accessing - defaults'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
defaultFileSuffix
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
    ^'Test'
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    "Created: / 04-08-2011 / 12:56:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
defaultFormat
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    "superclass HDReport says that I am responsible to implement this method"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    ^ Builder::TestReportFormat::JUnit new
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    "Created: / 04-08-2011 / 11:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
defaultName
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
    ^String streamContents:[:s|
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
        suite tests do:[:suite|
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
            s nextPutAll: suite name
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
        ] separatedBy:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
            s nextPut:$,;space
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
        ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
    ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    "Created: / 07-11-2011 / 09:47:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    66
!TestReport methodsFor:'command line options'!
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    67
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    68
cmdlineOptionCoverage
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    69
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    70
    ^CmdLineOption new
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    71
        short: $c;
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    72
        long: 'coverage';
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    73
        description: 'collect code coverage when running tests';
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    74
        action:[
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    75
            coverage := CoverageReport new.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    76
        ]
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    77
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
    78
    "Created: / 25-06-2013 / 15:36:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    79
    "Modified: / 27-05-2014 / 16:54:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    80
!
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    81
246
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    82
cmdlineOptionDropStdout
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    83
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    84
    ^CmdLineOption new
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    85
        long: 'drop-stdout';
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    86
        description: 'Do not include stdout in report';
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    87
        action:[
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    88
            keepStdout := false
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    89
        ]
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    90
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    91
    "Created: / 08-08-2014 / 11:48:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    92
!
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
    93
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    94
cmdlineOptionInstrument
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    95
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    96
    ^CmdLineOption new
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    97
        short: $I;
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    98
        long: 'instrument';
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
    99
        description: 'extra package to instrument for coverage (implies --coverage)';
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   100
        action:[:package |
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   101
            instrument isNil ifTrue:[ 
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   102
                instrument := Set new.
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   103
            ].
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   104
            instrument add: package.
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   105
            coverage isNil ifTrue:[ 
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   106
                coverage := CoverageReport new.
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   107
            ].
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   108
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   109
        ]
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   110
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   111
    "Created: / 27-05-2014 / 16:34:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
241
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   112
!
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   113
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   114
cmdlineOptionKeepStdout
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   115
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   116
    ^CmdLineOption new
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   117
        long: 'keep-stdout';
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   118
        description: 'Keep stdout and include it in report (may generate huge report!!)';
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   119
        action:[
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   120
            keepStdout := true
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   121
        ]
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   122
9879c8960574 Added option --keep-stdout to TestReport to include stdout contents in reports.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 240
diff changeset
   123
    "Created: / 16-06-2014 / 10:42:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   124
! !
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   125
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
!TestReport methodsFor:'initialization'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
initialize
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
    suite := TestSuite new.
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   131
    coverage := nil.
246
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
   132
    keepStdout := true.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
246
f0957ea6444a Builder::TestReport changed back to *keep* stdout by default. Pass --drop-stdout
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 241
diff changeset
   134
    "Modified: / 08-08-2014 / 11:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
setupForClasses:classes
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   138
    "Setup the report to run given classes"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   140
    | suiteFromClasses |
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   142
    suiteFromClasses := TestSuite named:name.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    classes do:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
            [:cls | 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
            |tc|
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
            cls isTestCaseLike 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
                ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
                    [ tc := cls asTestCase.
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   150
                    tc isAbstract ifFalse:[ suiteFromClasses addTest:tc suite ] ] ].
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   152
    self setupForSuite: suiteFromClasses.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
    "Created: / 04-08-2011 / 14:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   157
setupForPackages:pkgs 
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   159
    pkgs do: [:pkg | 
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
        |def |
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
80
eb88d790573d Loads the package if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 74
diff changeset
   162
        self loadPackageIfNotAlready: pkg.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
        def := ProjectDefinition definitionClassForPackage:pkg.
80
eb88d790573d Loads the package if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 74
diff changeset
   164
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
        (def respondsTo:#testSuite) ifTrue:[ 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
            suite addTest:def testSuite 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
        ] ifFalse:[ 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
            | classes psuite |
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
            psuite := TestSuite named:pkg.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
            classes := def notNil 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
                        ifTrue:[ def classes ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
                        ifFalse:[ ProjectDefinition searchForClassesWithProject:pkg asSymbol ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
            classes do: [:cls | 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
                |tc|
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
                cls isTestCaseLike ifTrue: [ 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
                    tc := cls asTestCase.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
                    tc isAbstract ifFalse:[ 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
                        psuite addTest:tc suite
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
                    ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
                ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
            ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
            suite addTest: psuite.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
        ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
    ].
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   187
    coverage notNil ifTrue:[
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   188
        coverage setupForPackages: packages.
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   189
        instrument notNil ifTrue:[ 
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   190
            coverage setupForPackages: instrument.
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   191
        ].
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   192
    ]
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   194
    "Modified: / 27-05-2014 / 16:35:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   197
setupForSuite: suiteToAdd
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
90
995880ed753c comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 80
diff changeset
   199
    suite addTest: suiteToAdd.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
    "Created: / 06-11-2011 / 18:27:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
!TestReport methodsFor:'private'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
print: anObject on: aStream
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
    [ anObject printOn: aStream ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
        on: Error do:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
            [aStream 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
                nextPutAll: '** error when prining instance of ';
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
                nextPutAll: anObject class name;
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
                nextPutAll: '**']
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
    "Created: / 15-03-2011 / 22:09:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
!TestReport methodsFor:'running'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
runReport
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   222
    | result |
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
    result := Result new format:format.
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   224
    coverage notNil ifTrue:[
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   225
        InstrumentationContext  run:[
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   226
            suite run:result.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   227
        ].
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   228
        Transcript cr; cr.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   229
        Transcript show: 'COLLECTING COVERAGE...'.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   230
        coverage name: self name.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   231
        coverage run.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   232
    ] ifFalse:[
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   233
        suite run:result.
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   234
    ].
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   235
    Transcript cr; cr.
215
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   236
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   237
    result failureOutcomes do:[:failureOutcome |
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   238
        Transcript show: 'FAILED '.
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   239
        failureOutcome testCase printOn: Transcript.
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   240
        Transcript cr.
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   241
    ].
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   242
    result errorOutcomes do:[:errorOutcome |
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   243
        Transcript show: 'ERROR  '.
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   244
        errorOutcome testCase printOn: Transcript.
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   245
        Transcript cr.
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   246
    ].
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   247
    Transcript cr; cr.
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   248
    Transcript show: 'SUMMARY: '.
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   249
    result printOn: Transcript.
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   250
    Transcript cr.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
    "Created: / 04-08-2011 / 12:39:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
215
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   253
    "Modified: / 23-10-2013 / 11:48:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
!TestReport::Result methodsFor:'accessing'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   258
errorCount
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   259
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   260
    ^nerror
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   261
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   262
    "Created: / 31-01-2013 / 13:54:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   263
!
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   264
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   265
exceptions
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   266
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   267
    ^super exceptions , HaltInterrupt
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   268
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   269
    "Created: / 03-08-2011 / 14:59:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   270
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   271
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   272
failureCount
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   273
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   274
    ^nfailed
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   275
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   276
    "Created: / 31-01-2013 / 13:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   277
!
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   278
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
format
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
    ^ format
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   281
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
format:aFormat
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   284
    format := aFormat.
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   285
!
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   286
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   287
passedCount
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   288
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   289
    ^npassed
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   290
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   291
    "Created: / 31-01-2013 / 13:54:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   292
!
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   293
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   294
skippedCount
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   295
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   296
    ^nskipped
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   297
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   298
    "Created: / 31-01-2013 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   299
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   300
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   301
!TestReport::Result methodsFor:'adding'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   302
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   303
addError: testcase detail: exception
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   304
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   305
    outcome result: (TestResult stateError).
247
7387f32855da Correctly capture and report stdout.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 246
diff changeset
   306
    outcome collectedOutput: collector contents. 
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   307
    format writeTestCase: testcase outcome: outcome time: time exception: exception.
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   308
    Transcript show:'...ERROR'.
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   309
    Logger trace: 'Finised %1>>%2, result ERROR' with: testcase nameForHDTestReport with: testcase selectorForHDTestReport.
215
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   310
    self errorOutcomes add:outcome.      
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   311
    nerror := nerror + 1.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
    "Created: / 03-08-2011 / 15:00:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   314
    "Modified: / 29-10-2014 / 14:02:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   316
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
addFailure: testcase detail: exception
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   318
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   319
    outcome result: (TestResult stateFail).
247
7387f32855da Correctly capture and report stdout.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 246
diff changeset
   320
    outcome collectedOutput: collector contents. 
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   321
    format writeTestCase: testcase outcome: outcome time: time exception: exception.
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   322
    Transcript show:'...FAILED'.
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   323
    Logger trace: 'Finised %1>>%2, result FAILED' with: testcase nameForHDTestReport with: testcase selectorForHDTestReport.
215
b6e13772ac08 class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 189
diff changeset
   324
    self failureOutcomes add: outcome.
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   325
    nfailed := nfailed + 1.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   326
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   327
    "Created: / 03-08-2011 / 15:00:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   328
    "Modified: / 29-10-2014 / 14:01:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   329
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   330
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   331
addPass: testcase
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   332
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   333
    outcome result: TestResult statePass.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   334
    format writeTestCase: testcase outcome: outcome time: time exception: nil.
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   335
    Transcript show:'...OK'.
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   336
    Logger trace: 'Finised %1>>%2, result PASSED' with: testcase nameForHDTestReport with: testcase selectorForHDTestReport.
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   337
    npassed := npassed + 1.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   338
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   339
    "Created: / 03-08-2011 / 15:19:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   340
    "Modified: / 29-10-2014 / 14:01:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
105
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   341
!
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   342
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   343
addSkipped: testcase
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   344
240
d10369beab55 Oops, fix for skipped tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 239
diff changeset
   345
    outcome := self createOutcome.
d10369beab55 Oops, fix for skipped tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 239
diff changeset
   346
    outcome testCase: testcase.        
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   347
    outcome result: TestResult stateSkip.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   348
    format writeTestCase: testcase outcome: outcome time: time exception: nil.
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   349
    Transcript show:'...SKIPPED'.
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   350
    Logger trace: 'Finised %1>>%2, result SKIPPED' with: testcase nameForHDTestReport with: testcase selectorForHDTestReport.
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   351
    nskipped := nskipped + 1.
105
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   352
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   353
    "Created: / 21-11-2012 / 15:35:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   354
    "Modified: / 29-10-2014 / 14:01:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   355
! !
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   356
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   357
!TestReport::Result methodsFor:'initialization'!
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   358
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   359
initialize
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   360
    super initialize.
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   361
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   362
    npassed := nfailed := nerror := nskipped := 0
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   363
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   364
    "Created: / 31-01-2013 / 13:52:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   365
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   366
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   367
!TestReport::Result methodsFor:'running'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   368
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   369
performCase:aTestCase 
251
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   370
    | savedStdout savedStderr savedTranscript encoder |
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   371
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   372
    savedStdout := Stdout.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   373
    savedStderr := Stdout.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   374
    savedTranscript := Transcript.
251
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   375
    encoder := OperatingSystem isMSWINDOWSlike 
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   376
                ifTrue:[ CharacterEncoder encoderForUTF8 ]
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   377
                ifFalse:[ CharacterEncoder encoderFor: OperatingSystem getCodeset ].
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   378
    collector := WriteStream on:(String new:100).
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   379
    [
251
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   380
        Stdout := SplittingWriteStream on:collector and: (EncodedStream stream: Stdout encoder: encoder).
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   381
        Stderr := SplittingWriteStream on:collector and: (EncodedStream stream: Stderr encoder: encoder).
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   382
        Transcript := SplittingWriteStream on:collector and: Transcript.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   383
        time := Time millisecondsToRun: [ super performCase: aTestCase ]
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   384
    ] ensure:[
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   385
        Stdout := savedStdout.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   386
        Stderr := savedStderr.
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   387
        Transcript := savedTranscript.
247
7387f32855da Correctly capture and report stdout.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 246
diff changeset
   388
        outcome collectedOutput: nil. "/ flush it, it has been written to output already
7387f32855da Correctly capture and report stdout.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 246
diff changeset
   389
        collector := nil.
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   390
    ].
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   391
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   392
    "Created: / 03-08-2011 / 18:40:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
251
cb6ebbd8d1c0 Fixed setup of a SplittingStream when running tests - wrap Stdout / Stderr to an EncodedStream
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 250
diff changeset
   393
    "Modified: / 07-12-2014 / 01:12:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   394
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   395
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   396
runCase:aTestCase debugged: debugged 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   397
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   398
    | timeout |
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   399
    timeout := aTestCase timeout.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   400
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   401
    self runCase: aTestCase debugged: debugged 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   402
         fork:  (aTestCase shouldFork or:[timeout notNil])
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   403
         timeout: timeout ? 60"sec"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   404
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   405
    "Created: / 22-08-2011 / 14:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   406
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   407
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   408
runCase:aTestCase debugged: debugged fork:doFork
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   409
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   410
    ^self runCase:aTestCase debugged: debugged 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   411
          fork:doFork timeout: aTestCase timeout ? 60"sec"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   412
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   413
    "Created: / 22-08-2011 / 14:38:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   414
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   415
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   416
runCase:aTestCase debugged: debugged fork:doFork timeout: tout
109
7a93688e5642 Make use of TestCase>>shouldSkip
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 105
diff changeset
   417
    | nm sel |
105
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   418
189
bd2bed33aba7 Fixes to make it running on Smalltalk/X 6.2.2 released in July 2012
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   419
    (aTestCase perform: #shouldSkip ifNotUnderstood:[false]) ifTrue:[
105
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   420
        self addSkipped: aTestCase.
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   421
        ^self.
15beda6b5f6e Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
   422
    ].
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   423
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   424
    nm := aTestCase nameForHDTestReport.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   425
    nm size > 20 ifTrue:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   426
        nm := (nm copyTo: 17) , '...'
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   427
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   428
    sel := aTestCase selectorForHDTestReport.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   429
    sel size > 20 ifTrue:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   430
        sel := '...' , (sel copyFrom: sel size - 16 to: sel size)
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   431
    ].
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   432
    Transcript showCR:('%1 >> #%2' bindWith: aTestCase nameForHDTestReport with: aTestCase selectorForHDTestReport).
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   433
    Transcript show:('%-20s >> %-20s : ' printfWith: nm with: sel).
234
b48196ea5f68 Better command line help for standalone report runner.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 215
diff changeset
   434
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   435
    outcome := self createOutcome.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   436
    outcome testCase: aTestCase.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   437
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   438
    doFork ifFalse:[ 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   439
        super runCase:aTestCase debugged: debugged.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   440
        Transcript cr.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   441
        ^self.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   442
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   443
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   444
    OperatingSystem isUNIXlike ifTrue:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   445
"/        self unixForkCase: aTestCase debugged: debugged.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   446
"/      Use lightweight forking
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   447
        self lightForkCase: aTestCase debugged: debugged timeout: tout.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   448
        ^ self.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   449
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   450
    OperatingSystem isMSWINDOWSlike ifTrue:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   451
        self lightForkCase: aTestCase debugged: debugged timeout: tout.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   452
        ^ self.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   453
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   454
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   455
    self error:'Unssuported platform'
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   456
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   457
    "Created: / 12-01-2012 / 17:52:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   458
    "Modified: / 29-10-2014 / 13:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   459
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   460
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   461
!TestReport::Result methodsFor:'running-private'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   462
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   463
lightForkCase:aTestCase debugged: debugged timeout: timeout
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   464
    | thread sema stime etime timeouted error stack log logPos |
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   465
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   466
    Logger trace: 'Running %1>>%2' with: aTestCase nameForHDTestReport with: aTestCase selectorForHDTestReport.
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   467
    Transcript show:'F'.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   468
    sema := Semaphore new.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   469
    stime := OperatingSystem getMillisecondTime.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   470
    log := false.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   471
    logPos := format stream stream position.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   472
    timeouted := false.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   473
    thread := [ super runCase:aTestCase debugged: debugged ] newProcess.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   474
    thread addExitAction:[sema signal].
237
8229efa1f621 Dump all threads when testcase times out.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 236
diff changeset
   475
    thread name: ('Testcase execution thread (%1)' bindWith: aTestCase).
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   476
    thread resume.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   477
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   478
    Transcript show: 'W'.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   479
    (sema waitWithTimeout:timeout) isNil ifTrue: [
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   480
        Transcript show: 'T'.
237
8229efa1f621 Dump all threads when testcase times out.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 236
diff changeset
   481
        stack := String streamContents:[:s |  ReportRunner dumpProcessesOn:s ].
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   482
        thread terminate.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   483
        timeouted := true.
239
517a62e9f9ab Display one-char messages to make output shorter.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 237
diff changeset
   484
        Transcript show: 'K'.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   485
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   486
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   487
    etime := OperatingSystem getMillisecondTime.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   488
    timeouted ifTrue:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   489
        error := TimeoutError new messageText: 'Timed out'.
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   490
        outcome result: TestResult stateError.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   491
        format 
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   492
            writeTestCase: aTestCase outcome: outcome 
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   493
                     time: etime - stime
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   494
                exception: error
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   495
               stacktrace: stack.
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   496
         Transcript show:'...ERROR'.
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   497
         Logger trace: 'Finised %1>>%2, result ERROR (timeout)' with: aTestCase nameForHDTestReport with: aTestCase selectorForHDTestReport.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   498
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   499
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   500
    outcome := nil.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   501
    Transcript cr.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   502
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   503
    "Created: / 12-01-2012 / 17:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
250
4392c84aaf1c Log start and end of individual tests.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 249
diff changeset
   504
    "Modified: / 29-10-2014 / 13:59:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   505
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   506
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   507
unixForkCase:aTestCase debugged: debugged timeout: timeout
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   508
    | pid status sema stime etime error stack suiteFailuresBefore suiteErrorsBefore log logPos |
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   509
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   510
    Transcript show:'forking...'.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   511
    sema := Semaphore new.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   512
    stime := OperatingSystem getMillisecondTime.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   513
    log := false.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   514
    logPos := format stream stream position.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   515
    Processor monitor:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   516
            [ pid := OperatingSystem fork.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   517
            pid == 0 ifTrue:[ nil ] ifFalse:[ pid ] ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   518
        action:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   519
            [:s | 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   520
            Transcript show:'child finished...'.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   521
            status := s.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   522
            sema signal ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   523
    pid == 0 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   524
        ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   525
            [ "Child, exit codes:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   526
             0...PASSED
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   527
             1...FAILED
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   528
             2...ERROR
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   529
           >64...got signal <code>-64"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   530
            
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   531
            [ suiteFailuresBefore := failures.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   532
            suiteErrorsBefore := errors.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   533
            super runCase:aTestCase debugged: debugged.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   534
            suiteErrorsBefore ~~ errors ifTrue:[ Smalltalk exit:2 ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   535
            suiteFailuresBefore ~~ failures ifTrue:[ Smalltalk exit:1 ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   536
            format streamClose.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   537
            Smalltalk exit:0. ] on:OSSignalInterrupt
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   538
                    do:[:ex | format streamClose. Smalltalk exit:64 + ex parameter ] ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   539
        ifFalse:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   540
            [ "Parent"
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   541
            format streamClose.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   542
            Transcript show: 'waiting for child...'.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   543
            (sema waitWithTimeout:timeout) isNil 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   544
                ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   545
                    [Transcript show: 'timeout...'.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   546
                    OperatingSystem terminateProcess:pid.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   547
                    OperatingSystem childProcessWait:true pid:pid.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   548
                    Transcript show: 'killed...'.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   549
                    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   550
            etime := OperatingSystem getMillisecondTime.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   551
            (status isNil or:[ status success not ]) 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   552
                ifFalse:[
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   553
                    "/child finished, result is pass. However, it is not in my passed collection
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   554
                    "/since addPass: has been called in child process
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   555
                   super addPass: aTestCase.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   556
                ] ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   557
                    [ log := true.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   558
                    status isNil 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   559
                        ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   560
                            [ error := TimeoutError new parameter:timeout.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   561
                            stack := 'Oops, timed out!! (timeout was ' , timeout printString , ' sec)'. ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   562
                        ifFalse:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   563
                            [ status status == #signal 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   564
                                ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   565
                                    [ error := OSSignalInterrupt new parameter:status code.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   566
                                    stack := 'Oops, VM terminated on signal ' , status code printString, ' (stactrace not awailable)' ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   567
                            status status == #exit 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   568
                                ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   569
                                    [ status code == 1 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   570
                                        ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   571
                                            [super addFailure: aTestCase detail: nil.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   572
                                            log := false ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   573
                                    status code == 2 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   574
                                        ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   575
                                            [super addError: aTestCase detail: nil.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   576
                                            log := false ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   577
                                    status code > 64 
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   578
                                        ifTrue:
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   579
                                            [ error := OSSignalInterrupt new parameter:status code - 64.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   580
                                            stack := 'Oops, VM terminated on signal ' , status code p ] ] ]. ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   581
            format streamOpenForAppend.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   582
            log ifTrue:[
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   583
                     outcome result: TestResult stateError.
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   584
                     format stream stream position: logPos.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   585
                     format 
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   586
                        writeTestCase: aTestCase outcome: outcome 
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   587
                                 time: etime - stime
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   588
                            exception: error
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   589
                           stacktrace: stack.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   590
                     Transcript show:'ERROR'
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   591
            ]
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   592
    ].
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   593
    outcome := nil.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   594
    Transcript cr.
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   595
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   596
    "Created: / 12-01-2012 / 17:43:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
236
475480551293 When running SUnit tests, capture and log stdout, stderr and Transcript and include it in XML report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 234
diff changeset
   597
    "Modified: / 06-06-2014 / 00:54:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   598
! !
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   599
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   600
!TestReport class methodsFor:'documentation'!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   601
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   602
version
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   603
    ^ '$Header$'
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   604
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   605
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   606
version_CVS
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   607
    ^ '$Header$'
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   608
!
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   609
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   610
version_SVN
164
707c2a3ef492 Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 111
diff changeset
   611
    ^ '$Id$'
74
d67d39f7b54e initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   612
! !
111
d0fa0756222b class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 109
diff changeset
   613