author | sr |
Tue, 29 May 2018 16:08:46 +0200 | |
changeset 519 | 1c3b66422a07 |
parent 251 | cb6ebbd8d1c0 |
child 303 | e217bb7aacf4 |
permissions | -rw-r--r-- |
74 | 1 |
"{ Package: 'stx:goodies/builder/reports' }" |
2 |
||
3 |
"{ NameSpace: Builder }" |
|
4 |
||
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 | 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 |
||
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 | 30 |
suite |
31 |
^ suite |
|
32 |
||
33 |
"Created: / 07-11-2011 / 09:41:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
34 |
! ! |
|
35 |
||
36 |
!TestReport methodsFor:'accessing - defaults'! |
|
37 |
||
38 |
defaultFileSuffix |
|
39 |
||
40 |
^'Test' |
|
41 |
||
42 |
"Created: / 04-08-2011 / 12:56:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
43 |
! |
|
44 |
||
45 |
defaultFormat |
|
46 |
"superclass HDReport says that I am responsible to implement this method" |
|
47 |
||
48 |
^ Builder::TestReportFormat::JUnit new |
|
49 |
||
50 |
"Created: / 04-08-2011 / 11:54:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
51 |
! |
|
52 |
||
53 |
defaultName |
|
54 |
||
55 |
^String streamContents:[:s| |
|
56 |
suite tests do:[:suite| |
|
57 |
s nextPutAll: suite name |
|
58 |
] separatedBy:[ |
|
59 |
s nextPut:$,;space |
|
60 |
] |
|
61 |
] |
|
62 |
||
63 |
"Created: / 07-11-2011 / 09:47:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
64 |
! ! |
|
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 | 126 |
!TestReport methodsFor:'initialization'! |
127 |
||
128 |
initialize |
|
129 |
||
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 | 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 | 135 |
! |
136 |
||
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 | 139 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
140 |
| suiteFromClasses | |
74 | 141 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
142 |
suiteFromClasses := TestSuite named:name. |
74 | 143 |
classes do: |
144 |
[:cls | |
|
145 |
|tc| |
|
146 |
||
147 |
cls isTestCaseLike |
|
148 |
ifTrue: |
|
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 | 151 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
152 |
self setupForSuite: suiteFromClasses. |
74 | 153 |
|
154 |
"Created: / 04-08-2011 / 14:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
155 |
! |
|
156 |
||
164
707c2a3ef492
Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
111
diff
changeset
|
157 |
setupForPackages:pkgs |
74 | 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 | 160 |
|def | |
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 | 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 | 165 |
(def respondsTo:#testSuite) ifTrue:[ |
166 |
suite addTest:def testSuite |
|
167 |
] ifFalse:[ |
|
168 |
| classes psuite | |
|
169 |
psuite := TestSuite named:pkg. |
|
170 |
||
171 |
classes := def notNil |
|
172 |
ifTrue:[ def classes ] |
|
173 |
ifFalse:[ ProjectDefinition searchForClassesWithProject:pkg asSymbol ]. |
|
174 |
classes do: [:cls | |
|
175 |
|tc| |
|
176 |
||
177 |
cls isTestCaseLike ifTrue: [ |
|
178 |
tc := cls asTestCase. |
|
179 |
tc isAbstract ifFalse:[ |
|
180 |
psuite addTest:tc suite |
|
181 |
] |
|
182 |
] |
|
183 |
]. |
|
184 |
suite addTest: psuite. |
|
185 |
] |
|
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 | 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 | 195 |
! |
196 |
||
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
197 |
setupForSuite: suiteToAdd |
74 | 198 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
199 |
suite addTest: suiteToAdd. |
74 | 200 |
|
201 |
"Created: / 06-11-2011 / 18:27:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
202 |
! ! |
|
203 |
||
204 |
!TestReport methodsFor:'private'! |
|
205 |
||
206 |
print: anObject on: aStream |
|
207 |
||
208 |
[ anObject printOn: aStream ] |
|
209 |
on: Error do: |
|
210 |
[aStream |
|
211 |
nextPutAll: '** error when prining instance of '; |
|
212 |
nextPutAll: anObject class name; |
|
213 |
nextPutAll: '**'] |
|
214 |
||
215 |
"Created: / 15-03-2011 / 22:09:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
216 |
! ! |
|
217 |
||
218 |
!TestReport methodsFor:'running'! |
|
219 |
||
220 |
runReport |
|
221 |
||
164
707c2a3ef492
Initial version of code coverage report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
111
diff
changeset
|
222 |
| result | |
74 | 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 | 251 |
|
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 | 254 |
! ! |
255 |
||
256 |
!TestReport::Result methodsFor:'accessing'! |
|
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 | 265 |
exceptions |
266 |
||
267 |
^super exceptions , HaltInterrupt |
|
268 |
||
269 |
"Created: / 03-08-2011 / 14:59:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
270 |
! |
|
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 | 279 |
format |
280 |
^ format |
|
281 |
! |
|
282 |
||
283 |
format:aFormat |
|
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 | 299 |
! ! |
300 |
||
301 |
!TestReport::Result methodsFor:'adding'! |
|
302 |
||
303 |
addError: testcase detail: exception |
|
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 | 312 |
|
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 | 315 |
! |
316 |
||
317 |
addFailure: testcase detail: exception |
|
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 | 326 |
|
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 | 329 |
! |
330 |
||
331 |
addPass: testcase |
|
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 | 338 |
|
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 | 365 |
! ! |
366 |
||
367 |
!TestReport::Result methodsFor:'running'! |
|
368 |
||
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 | 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 | 391 |
|
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 | 394 |
! |
395 |
||
396 |
runCase:aTestCase debugged: debugged |
|
397 |
||
398 |
| timeout | |
|
399 |
timeout := aTestCase timeout. |
|
400 |
||
401 |
self runCase: aTestCase debugged: debugged |
|
402 |
fork: (aTestCase shouldFork or:[timeout notNil]) |
|
403 |
timeout: timeout ? 60"sec" |
|
404 |
||
405 |
"Created: / 22-08-2011 / 14:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
406 |
! |
|
407 |
||
408 |
runCase:aTestCase debugged: debugged fork:doFork |
|
409 |
||
410 |
^self runCase:aTestCase debugged: debugged |
|
411 |
fork:doFork timeout: aTestCase timeout ? 60"sec" |
|
412 |
||
413 |
"Created: / 22-08-2011 / 14:38:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
414 |
! |
|
415 |
||
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 | 423 |
|
424 |
nm := aTestCase nameForHDTestReport. |
|
425 |
nm size > 20 ifTrue:[ |
|
426 |
nm := (nm copyTo: 17) , '...' |
|
427 |
]. |
|
428 |
sel := aTestCase selectorForHDTestReport. |
|
429 |
sel size > 20 ifTrue:[ |
|
430 |
sel := '...' , (sel copyFrom: sel size - 16 to: sel size) |
|
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 | 435 |
outcome := self createOutcome. |
436 |
outcome testCase: aTestCase. |
|
437 |
||
438 |
doFork ifFalse:[ |
|
439 |
super runCase:aTestCase debugged: debugged. |
|
440 |
Transcript cr. |
|
441 |
^self. |
|
442 |
]. |
|
443 |
||
444 |
OperatingSystem isUNIXlike ifTrue:[ |
|
445 |
"/ self unixForkCase: aTestCase debugged: debugged. |
|
446 |
"/ Use lightweight forking |
|
447 |
self lightForkCase: aTestCase debugged: debugged timeout: tout. |
|
448 |
^ self. |
|
449 |
]. |
|
450 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
451 |
self lightForkCase: aTestCase debugged: debugged timeout: tout. |
|
452 |
^ self. |
|
453 |
]. |
|
454 |
||
455 |
self error:'Unssuported platform' |
|
456 |
||
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 | 459 |
! ! |
460 |
||
461 |
!TestReport::Result methodsFor:'running-private'! |
|
462 |
||
463 |
lightForkCase:aTestCase debugged: debugged timeout: timeout |
|
464 |
| thread sema stime etime timeouted error stack log logPos | |
|
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 | 468 |
sema := Semaphore new. |
469 |
stime := OperatingSystem getMillisecondTime. |
|
470 |
log := false. |
|
471 |
logPos := format stream stream position. |
|
472 |
timeouted := false. |
|
473 |
thread := [ super runCase:aTestCase debugged: debugged ] newProcess. |
|
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 | 476 |
thread resume. |
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 | 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 | 482 |
thread terminate. |
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 | 485 |
]. |
486 |
||
487 |
etime := OperatingSystem getMillisecondTime. |
|
488 |
timeouted ifTrue:[ |
|
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 | 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 | 493 |
time: etime - stime |
494 |
exception: error |
|
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 | 498 |
]. |
499 |
||
500 |
outcome := nil. |
|
501 |
Transcript cr. |
|
502 |
||
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 | 505 |
! |
506 |
||
507 |
unixForkCase:aTestCase debugged: debugged timeout: timeout |
|
508 |
| pid status sema stime etime error stack suiteFailuresBefore suiteErrorsBefore log logPos | |
|
509 |
||
510 |
Transcript show:'forking...'. |
|
511 |
sema := Semaphore new. |
|
512 |
stime := OperatingSystem getMillisecondTime. |
|
513 |
log := false. |
|
514 |
logPos := format stream stream position. |
|
515 |
Processor monitor: |
|
516 |
[ pid := OperatingSystem fork. |
|
517 |
pid == 0 ifTrue:[ nil ] ifFalse:[ pid ] ] |
|
518 |
action: |
|
519 |
[:s | |
|
520 |
Transcript show:'child finished...'. |
|
521 |
status := s. |
|
522 |
sema signal ]. |
|
523 |
pid == 0 |
|
524 |
ifTrue: |
|
525 |
[ "Child, exit codes: |
|
526 |
0...PASSED |
|
527 |
1...FAILED |
|
528 |
2...ERROR |
|
529 |
>64...got signal <code>-64" |
|
530 |
||
531 |
[ suiteFailuresBefore := failures. |
|
532 |
suiteErrorsBefore := errors. |
|
533 |
super runCase:aTestCase debugged: debugged. |
|
534 |
suiteErrorsBefore ~~ errors ifTrue:[ Smalltalk exit:2 ]. |
|
535 |
suiteFailuresBefore ~~ failures ifTrue:[ Smalltalk exit:1 ]. |
|
536 |
format streamClose. |
|
537 |
Smalltalk exit:0. ] on:OSSignalInterrupt |
|
538 |
do:[:ex | format streamClose. Smalltalk exit:64 + ex parameter ] ] |
|
539 |
ifFalse: |
|
540 |
[ "Parent" |
|
541 |
format streamClose. |
|
542 |
Transcript show: 'waiting for child...'. |
|
543 |
(sema waitWithTimeout:timeout) isNil |
|
544 |
ifTrue: |
|
545 |
[Transcript show: 'timeout...'. |
|
546 |
OperatingSystem terminateProcess:pid. |
|
547 |
OperatingSystem childProcessWait:true pid:pid. |
|
548 |
Transcript show: 'killed...'. |
|
549 |
]. |
|
550 |
etime := OperatingSystem getMillisecondTime. |
|
551 |
(status isNil or:[ status success not ]) |
|
552 |
ifFalse:[ |
|
553 |
"/child finished, result is pass. However, it is not in my passed collection |
|
554 |
"/since addPass: has been called in child process |
|
555 |
super addPass: aTestCase. |
|
556 |
] ifTrue: |
|
557 |
[ log := true. |
|
558 |
status isNil |
|
559 |
ifTrue: |
|
560 |
[ error := TimeoutError new parameter:timeout. |
|
561 |
stack := 'Oops, timed out!! (timeout was ' , timeout printString , ' sec)'. ] |
|
562 |
ifFalse: |
|
563 |
[ status status == #signal |
|
564 |
ifTrue: |
|
565 |
[ error := OSSignalInterrupt new parameter:status code. |
|
566 |
stack := 'Oops, VM terminated on signal ' , status code printString, ' (stactrace not awailable)' ]. |
|
567 |
status status == #exit |
|
568 |
ifTrue: |
|
569 |
[ status code == 1 |
|
570 |
ifTrue: |
|
571 |
[super addFailure: aTestCase detail: nil. |
|
572 |
log := false ]. |
|
573 |
status code == 2 |
|
574 |
ifTrue: |
|
575 |
[super addError: aTestCase detail: nil. |
|
576 |
log := false ]. |
|
577 |
status code > 64 |
|
578 |
ifTrue: |
|
579 |
[ error := OSSignalInterrupt new parameter:status code - 64. |
|
580 |
stack := 'Oops, VM terminated on signal ' , status code p ] ] ]. ]. |
|
581 |
format streamOpenForAppend. |
|
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 | 584 |
format stream stream position: logPos. |
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 | 587 |
time: etime - stime |
588 |
exception: error |
|
589 |
stacktrace: stack. |
|
590 |
Transcript show:'ERROR' |
|
591 |
] |
|
592 |
]. |
|
593 |
outcome := nil. |
|
594 |
Transcript cr. |
|
595 |
||
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 | 598 |
! ! |
599 |
||
600 |
!TestReport class methodsFor:'documentation'! |
|
601 |
||
602 |
version |
|
603 |
^ '$Header$' |
|
604 |
! |
|
605 |
||
606 |
version_CVS |
|
607 |
^ '$Header$' |
|
608 |
! |
|
609 |
||
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 | 612 |
! ! |
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
613 |