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