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