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