447
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
349
|
3 |
"{ Package: 'stx:goodies/builder/quickSelfTest' }"
|
329
|
4 |
|
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
|
7 |
Object subclass:#RunUnitTests
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
|
11 |
category:'tests-Regression'
|
|
12 |
!
|
|
13 |
|
|
14 |
!RunUnitTests class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
538
|
18 |
typically invoked by RunUnitTestsStart
|
329
|
19 |
|
|
20 |
[author:]
|
543
|
21 |
sr
|
329
|
22 |
|
|
23 |
[instance variables:]
|
|
24 |
|
|
25 |
[class variables:]
|
|
26 |
|
|
27 |
[see also:]
|
|
28 |
|
|
29 |
"
|
|
30 |
! !
|
|
31 |
|
|
32 |
!RunUnitTests class methodsFor:'actions'!
|
|
33 |
|
|
34 |
run
|
400
|
35 |
self runWithCompiledUnitTestClasses:false.
|
398
|
36 |
!
|
|
37 |
|
|
38 |
runWithCompiledUnitTestClasses:useCompiledUnitTestClasses
|
426
|
39 |
|cmdArgs|
|
|
40 |
|
|
41 |
cmdArgs := Smalltalk commandLineArguments.
|
514
|
42 |
|
|
43 |
self
|
|
44 |
runWithCompiledUnitTestClasses:useCompiledUnitTestClasses
|
|
45 |
arguments:cmdArgs
|
|
46 |
debug:(cmdArgs includes:'--debug')
|
426
|
47 |
!
|
|
48 |
|
|
49 |
runWithCompiledUnitTestClasses:useCompiledUnitTestClasses
|
538
|
50 |
arguments:argumentsIn
|
426
|
51 |
debug:debug
|
|
52 |
|
538
|
53 |
|arguments
|
|
54 |
doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames
|
398
|
55 |
unitTestSuite
|
427
|
56 |
eachClass
|
419
|
57 |
result index
|
538
|
58 |
settingsFilePathName resultFilePathName forceTestCase runTestCases|
|
398
|
59 |
|
538
|
60 |
arguments := argumentsIn asOrderedCollection.
|
|
61 |
|
|
62 |
runTestCases := OrderedCollection new.
|
398
|
63 |
doRunSpecificUnitTests := false.
|
|
64 |
unitTestSuiteName := 'All Unit Tests'.
|
|
65 |
excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll.
|
|
66 |
corruptedUnitTestClassNames := self corruptedUnitTestClassNames.
|
|
67 |
|
447
|
68 |
index := arguments indexOf:'--settingsFile'.
|
398
|
69 |
index > 0 ifTrue:[
|
543
|
70 |
settingsFilePathName := arguments at:index + 1.
|
|
71 |
self logInfo:'load settings file: %1' with:settingsFilePathName.
|
|
72 |
settingsFilePathName asFilename fileIn.
|
|
73 |
self logInfo:'makeCommand (from ParserFlags) is: %1' with:(ParserFlags makeCommand).
|
418
|
74 |
].
|
|
75 |
|
447
|
76 |
(arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[
|
543
|
77 |
self logInfo:'configured to run expecco unit tests only'.
|
|
78 |
doRunSpecificUnitTests := true.
|
|
79 |
unitTestSuiteName := 'expecco Unit Tests'.
|
|
80 |
excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco.
|
398
|
81 |
].
|
|
82 |
|
447
|
83 |
index := arguments indexOf:'--resultFile'.
|
413
|
84 |
index > 0 ifTrue:[
|
543
|
85 |
resultFilePathName := arguments at:index + 1.
|
|
86 |
self logInfo:'set custom result file: %1' with:resultFilePathName.
|
|
87 |
].
|
|
88 |
|
|
89 |
[
|
|
90 |
(index := arguments indexOf:'--run') > 0
|
|
91 |
] whileTrue:[
|
|
92 |
runTestCases add:(arguments at:index + 1).
|
|
93 |
self logInfo:'run test: "%1"' with:(arguments at:index + 1).
|
|
94 |
arguments removeIndex:index + 1.
|
|
95 |
arguments removeIndex:index.
|
413
|
96 |
].
|
|
97 |
|
543
|
98 |
[
|
|
99 |
(index := arguments indexOf:'--exclude') > 0
|
538
|
100 |
] whileTrue:[
|
543
|
101 |
excludedUnitTestClassNames add:(arguments at:index + 1).
|
|
102 |
self logInfo:'exclude test: "%1"' with:(arguments at:index + 1).
|
|
103 |
arguments removeIndex:index + 1.
|
|
104 |
arguments removeIndex:index.
|
538
|
105 |
].
|
543
|
106 |
|
447
|
107 |
index := arguments indexOf:'--forceTestCase'.
|
418
|
108 |
index > 0 ifTrue:[
|
543
|
109 |
forceTestCase := arguments at:index + 1.
|
|
110 |
self logInfo:'run single test (forceTestCase): "%1"' with:forceTestCase.
|
419
|
111 |
].
|
398
|
112 |
|
543
|
113 |
(doRunSpecificUnitTests not and:[forceTestCase isNil]) ifTrue:[
|
|
114 |
self logInfo:'configured to run all available unit tests'.
|
398
|
115 |
].
|
|
116 |
|
543
|
117 |
"/ self logInfo:'collecting tests to run'.
|
398
|
118 |
unitTestSuite := TestSuite named:unitTestSuiteName.
|
|
119 |
|
427
|
120 |
(Smalltalk at: #'stx_goodies_regression') classNames do:[:eachClassName |
|
543
|
121 |
(excludedUnitTestClassNames includes:eachClassName) ifTrue:[
|
|
122 |
self logInfo:'exclude test "%1".' with:eachClassName.
|
|
123 |
] ifFalse:[
|
|
124 |
(corruptedUnitTestClassNames includes:eachClassName) ifTrue:[
|
|
125 |
self logWarning:'test "%1" is marked as corrupted, please fix' with:eachClassName.
|
|
126 |
] ifFalse:[
|
|
127 |
(eachClassName notNil
|
|
128 |
and:[
|
|
129 |
"/ skip non test class classes
|
|
130 |
(#(
|
|
131 |
'stx_goodies_regression'
|
|
132 |
) includes:eachClassName) not
|
|
133 |
and:[
|
|
134 |
forceTestCase isNil
|
|
135 |
or:[forceTestCase = eachClassName
|
|
136 |
or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]]
|
|
137 |
]]) ifTrue:[
|
|
138 |
eachClass := Smalltalk at:eachClassName.
|
407
|
139 |
|
543
|
140 |
useCompiledUnitTestClasses ifFalse:[
|
|
141 |
"here we want to test the jitter code
|
|
142 |
therfore we file in, exit if the class is already present somwhow"
|
|
143 |
eachClass notNil ifTrue:[
|
|
144 |
self logWarning:'test class "%1" was already present as stc-compiled class before file in.' with:eachClassName.
|
|
145 |
Smalltalk isSmalltalkDevelopmentSystem ifFalse:[
|
|
146 |
Smalltalk exit:1.
|
|
147 |
].
|
|
148 |
].
|
407
|
149 |
|
543
|
150 |
eachClass := Smalltalk
|
|
151 |
fileInClass:eachClassName
|
|
152 |
package:'stx:goodies/regression'.
|
|
153 |
].
|
422
|
154 |
|
543
|
155 |
eachClass notNil ifTrue:[
|
|
156 |
(eachClass isTestCaseLike
|
|
157 |
and:[eachClass isAbstract not]) ifTrue:[
|
|
158 |
self logInfo:'added test "%1".' with:eachClassName.
|
|
159 |
unitTestSuite addTest:eachClass suite.
|
|
160 |
] ifFalse:[
|
|
161 |
self logInfo:'not a test "%1" (abstract or something else).'
|
|
162 |
with:eachClassName.
|
|
163 |
].
|
|
164 |
] ifFalse:[
|
|
165 |
self logWarning:'test class "%1" is not loaded.' with:eachClassName.
|
|
166 |
].
|
|
167 |
] ifFalse:[
|
|
168 |
self logInfo:'skipped test "%1".' with:eachClassName.
|
|
169 |
].
|
|
170 |
].
|
|
171 |
].
|
398
|
172 |
].
|
|
173 |
|
543
|
174 |
self logInfo:'%1 unit test classes collected' with:unitTestSuite tests size.
|
398
|
175 |
|
538
|
176 |
self logInfo:'start tests...'.
|
398
|
177 |
result := unitTestSuite
|
543
|
178 |
run:TestResultStX new
|
|
179 |
beforeEachDo:[:test |
|
|
180 |
self logInfo:'performing unit test "%1"' with:test printString
|
|
181 |
]
|
|
182 |
afterEachDo:[:test :result|
|
|
183 |
|execTime status|
|
|
184 |
|
|
185 |
execTime := result lastOutcome executionTimeDuration.
|
544
|
186 |
status := result lastOutcome result.
|
543
|
187 |
self logInfo:' Status: %1 (exec. Time: %2)' with:status with:execTime.
|
|
188 |
]
|
|
189 |
debug:debug.
|
398
|
190 |
|
538
|
191 |
self logInfo:'tests finished.'.
|
543
|
192 |
|
538
|
193 |
self logInfo:'generating xml report...'.
|
543
|
194 |
[
|
|
195 |
TestResultReporter
|
|
196 |
report:result
|
|
197 |
format:#xml_jUnit
|
|
198 |
as:(resultFilePathName ? 'testresult.xml').
|
|
199 |
] on:Error do:[:ex |
|
|
200 |
self logWarning:'error while generating xml report: %1' with:ex description.
|
|
201 |
self logWarning:'in: %1' with:(ex suspendedContext fullPrintAllString).
|
|
202 |
Smalltalk isSmalltalkDevelopmentSystem ifFalse:[
|
|
203 |
Smalltalk exit:1.
|
|
204 |
].
|
|
205 |
].
|
398
|
206 |
|
543
|
207 |
self logInfo:'xml report generated in %1' with:(resultFilePathName ? 'testresult.xml') asFilename pathName.
|
538
|
208 |
|
|
209 |
self logInfo:'Summary:'.
|
543
|
210 |
self logInfo:' %1 tests' with:result tests size.
|
|
211 |
self logInfo:' %1 run' with:result runCount.
|
|
212 |
self logInfo:' %1 skipped' with:result skippedCount.
|
|
213 |
self logInfo:' %1 passed' with:result passedCount.
|
|
214 |
self logInfo:' %1 failed' with:result failureCount.
|
|
215 |
self logInfo:' %1 errors' with:result errorCount.
|
|
216 |
self logInfo:' exec. time: %1' with:(TimeDuration fromSeconds:result executionTime).
|
515
|
217 |
|
|
218 |
"Modified (format): / 16-05-2018 / 13:59:47 / sr"
|
538
|
219 |
"Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger"
|
329
|
220 |
! !
|
|
221 |
|
|
222 |
!RunUnitTests class methodsFor:'constants'!
|
|
223 |
|
|
224 |
corruptedUnitTestClassNames
|
|
225 |
^ #(
|
336
|
226 |
#'RegressionTests::ExternalInterfaceTests'
|
|
227 |
#'RegressionTests::DebuggerTest'
|
345
|
228 |
#'RegressionTests::ContextTest2'
|
329
|
229 |
)
|
|
230 |
!
|
|
231 |
|
|
232 |
excludedUnitTestClassNamesForAll
|
419
|
233 |
^ #(
|
|
234 |
#'RegressionTests::SelectorNamespacesTests'
|
|
235 |
)
|
329
|
236 |
!
|
|
237 |
|
336
|
238 |
excludedUnitTestClassNamesForExpecco
|
329
|
239 |
^ self excludedUnitTestClassNamesForAll
|
410
|
240 |
, #(
|
424
|
241 |
#'RegressionTests::VMCrashTestCase'
|
419
|
242 |
#'RegressionTests::VMCrashTests'
|
420
|
243 |
#'RegressionTests::ParserTests'
|
410
|
244 |
#'RegressionTests::BreakpointTests'
|
|
245 |
#'RegressionTests::SunitXMLOutputTest'
|
|
246 |
#'RegressionTests::CompilerTests2'
|
|
247 |
#'RegressionTests::BehaviorLookupObjectTests'
|
|
248 |
#'RegressionTests::ChangeSetTests'
|
|
249 |
#'RegressionTests::MakefileTests'
|
|
250 |
#'RegressionTests::MetaphoneStringComparatorTest'
|
|
251 |
#'RegressionTests::STCCompilerTests'
|
|
252 |
#'RegressionTests::VMCrashTests'
|
|
253 |
#'RegressionTests::SnapshotRestartTests'
|
|
254 |
#'RegressionTests::GraphicDrawingTest'
|
|
255 |
#'RegressionTests::OS_OLE_Tests'
|
|
256 |
#'RegressionTests::ExternalInterfaceTests'
|
|
257 |
#'RegressionTests::DebuggerTest'
|
|
258 |
#'RegressionTests::ContextTest2'
|
415
|
259 |
#'RegressionTests::QDoubleTests'
|
410
|
260 |
)
|
329
|
261 |
! !
|
|
262 |
|
428
|
263 |
!RunUnitTests class methodsFor:'examples'!
|
|
264 |
|
|
265 |
example1
|
|
266 |
Processor activeProcess exceptionHandlerSet
|
514
|
267 |
on:Class updateChangeFileQuerySignal
|
|
268 |
do:[:ex | ex proceedWith:false].
|
428
|
269 |
|
|
270 |
self
|
514
|
271 |
runWithCompiledUnitTestClasses:true
|
|
272 |
arguments:#(
|
|
273 |
'--runOnlyExpeccoUnitTests'
|
|
274 |
'--forceTestCase'
|
|
275 |
'ExternalStreamTest'
|
|
276 |
)
|
|
277 |
debug:true
|
538
|
278 |
!
|
|
279 |
|
|
280 |
example2
|
|
281 |
Processor activeProcess exceptionHandlerSet
|
543
|
282 |
on:Class updateChangeFileQuerySignal
|
|
283 |
do:[:ex | ex proceedWith:false].
|
538
|
284 |
|
|
285 |
self
|
543
|
286 |
runWithCompiledUnitTestClasses:true
|
|
287 |
arguments:#(
|
|
288 |
'--forceTestCase'
|
|
289 |
'RegressionTests::ExternalStreamTest'
|
|
290 |
)
|
|
291 |
debug:true
|
538
|
292 |
|
|
293 |
"Created: / 26-03-2019 / 18:46:46 / Claus Gittinger"
|
|
294 |
!
|
|
295 |
|
|
296 |
example2b
|
|
297 |
Processor activeProcess exceptionHandlerSet
|
543
|
298 |
on:Class updateChangeFileQuerySignal
|
|
299 |
do:[:ex | ex proceedWith:false].
|
538
|
300 |
|
|
301 |
self
|
543
|
302 |
runWithCompiledUnitTestClasses:true
|
|
303 |
arguments:#(
|
|
304 |
'--forceTestCase'
|
|
305 |
'ExternalStreamTest'
|
|
306 |
)
|
|
307 |
debug:true
|
538
|
308 |
|
|
309 |
"Created: / 26-03-2019 / 18:55:46 / Claus Gittinger"
|
|
310 |
!
|
|
311 |
|
|
312 |
example2c
|
|
313 |
Processor activeProcess exceptionHandlerSet
|
543
|
314 |
on:Class updateChangeFileQuerySignal
|
|
315 |
do:[:ex | ex proceedWith:false].
|
538
|
316 |
|
|
317 |
self
|
543
|
318 |
runWithCompiledUnitTestClasses:true
|
|
319 |
arguments:#(
|
|
320 |
'--forceTestCase'
|
|
321 |
'CRCTests'
|
|
322 |
)
|
|
323 |
debug:true
|
538
|
324 |
|
|
325 |
"Created: / 26-03-2019 / 18:58:36 / Claus Gittinger"
|
|
326 |
!
|
|
327 |
|
|
328 |
example3
|
|
329 |
Processor activeProcess exceptionHandlerSet
|
543
|
330 |
on:Class updateChangeFileQuerySignal
|
|
331 |
do:[:ex | ex proceedWith:false].
|
538
|
332 |
|
|
333 |
self
|
543
|
334 |
runWithCompiledUnitTestClasses:true
|
|
335 |
arguments:#(
|
|
336 |
'--run'
|
|
337 |
'ExternalStreamTest'
|
|
338 |
)
|
|
339 |
debug:true
|
538
|
340 |
|
|
341 |
"Created: / 26-03-2019 / 18:51:42 / Claus Gittinger"
|
428
|
342 |
! !
|
|
343 |
|
329
|
344 |
!RunUnitTests class methodsFor:'logging'!
|
|
345 |
|
538
|
346 |
log:aString type:aType
|
|
347 |
Transcript notNil ifTrue:[
|
543
|
348 |
Transcript showCR:'%1 [%2] : %3'
|
|
349 |
with:Timestamp now printString
|
|
350 |
with:(aType printString asLowercase paddedTo:'warning' size)
|
|
351 |
with:aString.
|
|
352 |
^ self
|
|
353 |
].
|
538
|
354 |
Stderr showCR:'%1 [%2] : %3'
|
543
|
355 |
with:Timestamp now printString
|
|
356 |
with:(aType printString asLowercase paddedTo:'warning' size)
|
|
357 |
with:aString.
|
329
|
358 |
|
538
|
359 |
"Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger"
|
329
|
360 |
!
|
|
361 |
|
|
362 |
logInfo:aString
|
543
|
363 |
self log:aString type:'INFO'
|
|
364 |
!
|
|
365 |
|
|
366 |
logInfo:aString with:arg
|
|
367 |
self log:(aString bindWith:arg) type:'INFO'
|
329
|
368 |
!
|
|
369 |
|
|
370 |
logWarning:aString
|
543
|
371 |
self log:aString type:'WARNING'
|
|
372 |
!
|
|
373 |
|
|
374 |
logWarning:aString with:arg
|
|
375 |
self log:(aString bindWith:arg) type:'WARNING'
|
329
|
376 |
! !
|
349
|
377 |
|
|
378 |
!RunUnitTests class methodsFor:'documentation'!
|
|
379 |
|
399
|
380 |
version
|
|
381 |
^ '$Header$'
|
|
382 |
!
|
|
383 |
|
349
|
384 |
version_CVS
|
|
385 |
^ '$Header$'
|
|
386 |
! !
|