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