author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 31 Jan 2013 14:56:16 +0100 | |
changeset 111 | d0fa0756222b |
parent 109 | 7a93688e5642 |
child 164 | 707c2a3ef492 |
permissions | -rw-r--r-- |
74 | 1 |
"{ Package: 'stx:goodies/builder/reports' }" |
2 |
||
3 |
"{ NameSpace: Builder }" |
|
4 |
||
5 |
Report subclass:#TestReport |
|
6 |
instanceVariableNames:'suite' |
|
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 |
||
58 |
!TestReport methodsFor:'initialization'! |
|
59 |
||
60 |
initialize |
|
61 |
||
62 |
suite := TestSuite new. |
|
63 |
||
64 |
"Modified: / 07-11-2011 / 09:40:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
65 |
! |
|
66 |
||
67 |
setupForClasses:classes |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
68 |
"Setup the report to run given classes" |
74 | 69 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
70 |
| suiteFromClasses | |
74 | 71 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
72 |
suiteFromClasses := TestSuite named:name. |
74 | 73 |
classes do: |
74 |
[:cls | |
|
75 |
|tc| |
|
76 |
||
77 |
cls isTestCaseLike |
|
78 |
ifTrue: |
|
79 |
[ tc := cls asTestCase. |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
80 |
tc isAbstract ifFalse:[ suiteFromClasses addTest:tc suite ] ] ]. |
74 | 81 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
82 |
self setupForSuite: suiteFromClasses. |
74 | 83 |
|
84 |
"Created: / 04-08-2011 / 14:34:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
85 |
! |
|
86 |
||
87 |
setupForPackages:packages |
|
88 |
||
89 |
packages do: [:pkg | |
|
90 |
|def | |
|
91 |
||
80
eb88d790573d
Loads the package if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
74
diff
changeset
|
92 |
self loadPackageIfNotAlready: pkg. |
74 | 93 |
def := ProjectDefinition definitionClassForPackage:pkg. |
80
eb88d790573d
Loads the package if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
74
diff
changeset
|
94 |
|
74 | 95 |
(def respondsTo:#testSuite) ifTrue:[ |
96 |
suite addTest:def testSuite |
|
97 |
] ifFalse:[ |
|
98 |
| classes psuite | |
|
99 |
psuite := TestSuite named:pkg. |
|
100 |
||
101 |
classes := def notNil |
|
102 |
ifTrue:[ def classes ] |
|
103 |
ifFalse:[ ProjectDefinition searchForClassesWithProject:pkg asSymbol ]. |
|
104 |
classes do: [:cls | |
|
105 |
|tc| |
|
106 |
||
107 |
cls isTestCaseLike ifTrue: [ |
|
108 |
tc := cls asTestCase. |
|
109 |
tc isAbstract ifFalse:[ |
|
110 |
psuite addTest:tc suite |
|
111 |
] |
|
112 |
] |
|
113 |
]. |
|
114 |
suite addTest: psuite. |
|
115 |
] |
|
116 |
]. |
|
117 |
||
80
eb88d790573d
Loads the package if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
74
diff
changeset
|
118 |
"Modified: / 13-01-2012 / 13:00:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 119 |
! |
120 |
||
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
121 |
setupForSuite: suiteToAdd |
74 | 122 |
|
90
995880ed753c
comment/format in: #setupForClasses:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
80
diff
changeset
|
123 |
suite addTest: suiteToAdd. |
74 | 124 |
|
125 |
"Created: / 06-11-2011 / 18:27:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
126 |
! ! |
|
127 |
||
128 |
!TestReport methodsFor:'private'! |
|
129 |
||
130 |
print: anObject on: aStream |
|
131 |
||
132 |
[ anObject printOn: aStream ] |
|
133 |
on: Error do: |
|
134 |
[aStream |
|
135 |
nextPutAll: '** error when prining instance of '; |
|
136 |
nextPutAll: anObject class name; |
|
137 |
nextPutAll: '**'] |
|
138 |
||
139 |
"Created: / 15-03-2011 / 22:09:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
! ! |
|
141 |
||
142 |
!TestReport methodsFor:'running'! |
|
143 |
||
144 |
runReport |
|
145 |
||
146 |
|result| |
|
147 |
result := Result new format:format. |
|
148 |
suite run:result. |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
149 |
Transcript cr; cr. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
150 |
Transcript show: 'SUMMARY: '. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
151 |
result printOn: Transcript. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
152 |
Transcript cr. |
74 | 153 |
|
154 |
"Created: / 04-08-2011 / 12:39:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
155 |
"Modified: / 31-01-2013 / 13:48:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 156 |
! ! |
157 |
||
158 |
!TestReport::Result methodsFor:'accessing'! |
|
159 |
||
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
160 |
errorCount |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
161 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
162 |
^nerror |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
163 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
164 |
"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
|
165 |
! |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
166 |
|
74 | 167 |
exceptions |
168 |
||
169 |
^super exceptions , HaltInterrupt |
|
170 |
||
171 |
"Created: / 03-08-2011 / 14:59:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
172 |
! |
|
173 |
||
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
174 |
failureCount |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
175 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
176 |
^nfailed |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
177 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
178 |
"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
|
179 |
! |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
180 |
|
74 | 181 |
format |
182 |
^ format |
|
183 |
! |
|
184 |
||
185 |
format:aFormat |
|
186 |
format := aFormat. |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
187 |
! |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
188 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
189 |
passedCount |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
190 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
191 |
^npassed |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
192 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
193 |
"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
|
194 |
! |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
195 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
196 |
skippedCount |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
197 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
198 |
^nskipped |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
199 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
200 |
"Created: / 31-01-2013 / 13:54:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 201 |
! ! |
202 |
||
203 |
!TestReport::Result methodsFor:'adding'! |
|
204 |
||
205 |
addError: testcase detail: exception |
|
206 |
||
207 |
format writeTestCase: testcase outcome: #error time: time exception: exception. |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
208 |
Transcript show:'ERROR'. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
209 |
nerror := nerror + 1. |
74 | 210 |
|
211 |
"Created: / 03-08-2011 / 15:00:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
212 |
"Modified: / 31-01-2013 / 13:52:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 213 |
! |
214 |
||
215 |
addFailure: testcase detail: exception |
|
216 |
||
217 |
format writeTestCase: testcase outcome: #failure time: time exception: exception. |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
218 |
Transcript show:'FAILED'. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
219 |
nfailed := nfailed + 1. |
74 | 220 |
|
221 |
"Created: / 03-08-2011 / 15:00:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
222 |
"Modified: / 31-01-2013 / 13:53:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 223 |
! |
224 |
||
225 |
addPass: testcase |
|
226 |
||
227 |
format writeTestCase: testcase outcome: #pass time: time exception: nil. |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
228 |
Transcript show:'OK'. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
229 |
npassed := npassed + 1. |
74 | 230 |
|
231 |
"Created: / 03-08-2011 / 15:19:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
232 |
"Modified: / 31-01-2013 / 13:53:12 / 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
|
233 |
! |
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
234 |
|
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
235 |
addSkipped: testcase |
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
236 |
|
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
237 |
format writeTestCase: testcase outcome: #skip time: time exception: nil. |
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
238 |
Transcript show:'SKIPPED'. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
239 |
nskipped := nskipped + 1. |
105
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
240 |
|
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
241 |
"Created: / 21-11-2012 / 15:35:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
242 |
"Modified: / 31-01-2013 / 13:53:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
243 |
! ! |
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 |
!TestReport::Result methodsFor:'initialization'! |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
246 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
247 |
initialize |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
248 |
super initialize. |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
249 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
250 |
npassed := nfailed := nerror := nskipped := 0 |
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
251 |
|
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
252 |
"Created: / 31-01-2013 / 13:52:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 253 |
! ! |
254 |
||
255 |
!TestReport::Result methodsFor:'running'! |
|
256 |
||
257 |
performCase:aTestCase |
|
258 |
||
259 |
time := Time millisecondsToRun: [ super performCase: aTestCase ] |
|
260 |
||
261 |
"Created: / 03-08-2011 / 18:40:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
262 |
! |
|
263 |
||
264 |
runCase:aTestCase debugged: debugged |
|
265 |
||
266 |
| timeout | |
|
267 |
timeout := aTestCase timeout. |
|
268 |
||
269 |
self runCase: aTestCase debugged: debugged |
|
270 |
fork: (aTestCase shouldFork or:[timeout notNil]) |
|
271 |
timeout: timeout ? 60"sec" |
|
272 |
||
273 |
"Created: / 22-08-2011 / 14:37:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
274 |
! |
|
275 |
||
276 |
runCase:aTestCase debugged: debugged fork:doFork |
|
277 |
||
278 |
^self runCase:aTestCase debugged: debugged |
|
279 |
fork:doFork timeout: aTestCase timeout ? 60"sec" |
|
280 |
||
281 |
"Created: / 22-08-2011 / 14:38:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
282 |
! |
|
283 |
||
284 |
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
|
285 |
| nm sel | |
105
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
286 |
|
109
7a93688e5642
Make use of TestCase>>shouldSkip
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
105
diff
changeset
|
287 |
aTestCase shouldSkip ifTrue:[ |
105
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
288 |
self addSkipped: aTestCase. |
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
289 |
^self. |
15beda6b5f6e
Added support for skipped/ignored tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
90
diff
changeset
|
290 |
]. |
74 | 291 |
|
292 |
nm := aTestCase nameForHDTestReport. |
|
293 |
nm size > 20 ifTrue:[ |
|
294 |
nm := (nm copyTo: 17) , '...' |
|
295 |
]. |
|
296 |
sel := aTestCase selectorForHDTestReport. |
|
297 |
sel size > 20 ifTrue:[ |
|
298 |
sel := '...' , (sel copyFrom: sel size - 16 to: sel size) |
|
299 |
]. |
|
300 |
Transcript show:('%-20s >> %-20s : ' printfWith: nm with: sel). |
|
301 |
||
302 |
outcome := self createOutcome. |
|
303 |
outcome testCase: aTestCase. |
|
304 |
||
305 |
doFork ifFalse:[ |
|
306 |
super runCase:aTestCase debugged: debugged. |
|
307 |
Transcript cr. |
|
308 |
^self. |
|
309 |
]. |
|
310 |
||
311 |
OperatingSystem isUNIXlike ifTrue:[ |
|
312 |
"/ self unixForkCase: aTestCase debugged: debugged. |
|
313 |
"/ Use lightweight forking |
|
314 |
self lightForkCase: aTestCase debugged: debugged timeout: tout. |
|
315 |
^ self. |
|
316 |
]. |
|
317 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
318 |
self lightForkCase: aTestCase debugged: debugged timeout: tout. |
|
319 |
^ self. |
|
320 |
]. |
|
321 |
||
322 |
self error:'Unssuported platform' |
|
323 |
||
324 |
"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
|
325 |
"Modified: / 28-11-2012 / 18:04:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 326 |
! ! |
327 |
||
328 |
!TestReport::Result methodsFor:'running-private'! |
|
329 |
||
330 |
lightForkCase:aTestCase debugged: debugged timeout: timeout |
|
331 |
| thread sema stime etime timeouted error stack log logPos | |
|
332 |
||
333 |
Transcript show:'forking...'. |
|
334 |
sema := Semaphore new. |
|
335 |
stime := OperatingSystem getMillisecondTime. |
|
336 |
log := false. |
|
337 |
logPos := format stream stream position. |
|
338 |
timeouted := false. |
|
339 |
thread := [ super runCase:aTestCase debugged: debugged ] newProcess. |
|
340 |
thread addExitAction:[sema signal]. |
|
341 |
thread resume. |
|
342 |
||
343 |
Transcript show: 'waiting for child...'. |
|
344 |
(sema waitWithTimeout:timeout) isNil ifTrue: [ |
|
345 |
Transcript show: 'timeout...'. |
|
346 |
thread terminate. |
|
347 |
timeouted := true. |
|
348 |
Transcript show: 'killed...'. |
|
349 |
]. |
|
350 |
||
351 |
etime := OperatingSystem getMillisecondTime. |
|
352 |
timeouted ifTrue:[ |
|
353 |
error := TimeoutError new messageText: 'Timed out'. |
|
354 |
stack := 'Timed out'. |
|
355 |
format |
|
356 |
writeTestCase: aTestCase outcome: #error |
|
357 |
time: etime - stime |
|
358 |
exception: error |
|
359 |
stacktrace: stack. |
|
360 |
Transcript show:'ERROR' |
|
361 |
]. |
|
362 |
||
363 |
outcome := nil. |
|
364 |
Transcript cr. |
|
365 |
||
366 |
"Created: / 12-01-2012 / 17:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
367 |
! |
|
368 |
||
369 |
unixForkCase:aTestCase debugged: debugged timeout: timeout |
|
370 |
| pid status sema stime etime error stack suiteFailuresBefore suiteErrorsBefore log logPos | |
|
371 |
||
372 |
Transcript show:'forking...'. |
|
373 |
sema := Semaphore new. |
|
374 |
stime := OperatingSystem getMillisecondTime. |
|
375 |
log := false. |
|
376 |
logPos := format stream stream position. |
|
377 |
Processor monitor: |
|
378 |
[ pid := OperatingSystem fork. |
|
379 |
pid == 0 ifTrue:[ nil ] ifFalse:[ pid ] ] |
|
380 |
action: |
|
381 |
[:s | |
|
382 |
Transcript show:'child finished...'. |
|
383 |
status := s. |
|
384 |
sema signal ]. |
|
385 |
pid == 0 |
|
386 |
ifTrue: |
|
387 |
[ "Child, exit codes: |
|
388 |
0...PASSED |
|
389 |
1...FAILED |
|
390 |
2...ERROR |
|
391 |
>64...got signal <code>-64" |
|
392 |
||
393 |
[ suiteFailuresBefore := failures. |
|
394 |
suiteErrorsBefore := errors. |
|
395 |
super runCase:aTestCase debugged: debugged. |
|
396 |
suiteErrorsBefore ~~ errors ifTrue:[ Smalltalk exit:2 ]. |
|
397 |
suiteFailuresBefore ~~ failures ifTrue:[ Smalltalk exit:1 ]. |
|
398 |
format streamClose. |
|
399 |
Smalltalk exit:0. ] on:OSSignalInterrupt |
|
400 |
do:[:ex | format streamClose. Smalltalk exit:64 + ex parameter ] ] |
|
401 |
ifFalse: |
|
402 |
[ "Parent" |
|
403 |
format streamClose. |
|
404 |
Transcript show: 'waiting for child...'. |
|
405 |
(sema waitWithTimeout:timeout) isNil |
|
406 |
ifTrue: |
|
407 |
[Transcript show: 'timeout...'. |
|
408 |
OperatingSystem terminateProcess:pid. |
|
409 |
OperatingSystem childProcessWait:true pid:pid. |
|
410 |
Transcript show: 'killed...'. |
|
411 |
]. |
|
412 |
etime := OperatingSystem getMillisecondTime. |
|
413 |
(status isNil or:[ status success not ]) |
|
414 |
ifFalse:[ |
|
415 |
"/child finished, result is pass. However, it is not in my passed collection |
|
416 |
"/since addPass: has been called in child process |
|
417 |
super addPass: aTestCase. |
|
418 |
] ifTrue: |
|
419 |
[ log := true. |
|
420 |
status isNil |
|
421 |
ifTrue: |
|
422 |
[ error := TimeoutError new parameter:timeout. |
|
423 |
stack := 'Oops, timed out!! (timeout was ' , timeout printString , ' sec)'. ] |
|
424 |
ifFalse: |
|
425 |
[ status status == #signal |
|
426 |
ifTrue: |
|
427 |
[ error := OSSignalInterrupt new parameter:status code. |
|
428 |
stack := 'Oops, VM terminated on signal ' , status code printString, ' (stactrace not awailable)' ]. |
|
429 |
status status == #exit |
|
430 |
ifTrue: |
|
431 |
[ status code == 1 |
|
432 |
ifTrue: |
|
433 |
[super addFailure: aTestCase detail: nil. |
|
434 |
log := false ]. |
|
435 |
status code == 2 |
|
436 |
ifTrue: |
|
437 |
[super addError: aTestCase detail: nil. |
|
438 |
log := false ]. |
|
439 |
status code > 64 |
|
440 |
ifTrue: |
|
441 |
[ error := OSSignalInterrupt new parameter:status code - 64. |
|
442 |
stack := 'Oops, VM terminated on signal ' , status code p ] ] ]. ]. |
|
443 |
format streamOpenForAppend. |
|
444 |
log ifTrue:[ |
|
445 |
format stream stream position: logPos. |
|
446 |
format |
|
447 |
writeTestCase: aTestCase outcome: #error |
|
448 |
time: etime - stime |
|
449 |
exception: error |
|
450 |
stacktrace: stack. |
|
451 |
Transcript show:'ERROR' |
|
452 |
] |
|
453 |
]. |
|
454 |
outcome := nil. |
|
455 |
Transcript cr. |
|
456 |
||
457 |
"Created: / 12-01-2012 / 17:43:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
458 |
! ! |
|
459 |
||
460 |
!TestReport class methodsFor:'documentation'! |
|
461 |
||
462 |
version |
|
463 |
^ '$Header$' |
|
464 |
! |
|
465 |
||
466 |
version_CVS |
|
467 |
^ '$Header$' |
|
468 |
! |
|
469 |
||
470 |
version_SVN |
|
471 |
^ '§Id: Builder__TestReport.st 300 2012-01-12 17:53:04Z vranyj1 §' |
|
472 |
! ! |
|
111
d0fa0756222b
class: Builder::TestReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
109
diff
changeset
|
473 |