65 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
65 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
66 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
66 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
67 |
67 |
68 index := arguments indexOf:'--settingsFile'. |
68 index := arguments indexOf:'--settingsFile'. |
69 index > 0 ifTrue:[ |
69 index > 0 ifTrue:[ |
70 settingsFilePathName := arguments at:index + 1. |
70 settingsFilePathName := arguments at:index + 1. |
71 self logInfo:'load settings file: ', settingsFilePathName printString. |
71 self logInfo:'load settings file: %1' with:settingsFilePathName. |
72 settingsFilePathName asFilename fileIn. |
72 settingsFilePathName asFilename fileIn. |
73 self logInfo:'ParserFlags makeCommand: ', ParserFlags makeCommand printString. |
73 self logInfo:'makeCommand (from ParserFlags) is: %1' with:(ParserFlags makeCommand). |
74 ]. |
74 ]. |
75 |
75 |
76 (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
76 (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
77 self logInfo:'configured to run expecco unit tests only'. |
77 self logInfo:'configured to run expecco unit tests only'. |
78 doRunSpecificUnitTests := true. |
78 doRunSpecificUnitTests := true. |
79 unitTestSuiteName := 'expecco Unit Tests'. |
79 unitTestSuiteName := 'expecco Unit Tests'. |
80 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
80 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
81 ]. |
81 ]. |
82 |
82 |
83 index := arguments indexOf:'--resultFile'. |
83 index := arguments indexOf:'--resultFile'. |
84 index > 0 ifTrue:[ |
84 index > 0 ifTrue:[ |
85 resultFilePathName := arguments at:index + 1. |
85 resultFilePathName := arguments at:index + 1. |
86 self logInfo:'set custom result file: ', resultFilePathName printString. |
86 self logInfo:'set custom result file: %1' with:resultFilePathName. |
87 ]. |
87 ]. |
88 |
88 |
89 [ |
89 [ |
90 (index := arguments indexOf:'--run') > 0 |
90 (index := arguments indexOf:'--run') > 0 |
91 ] whileTrue:[ |
91 ] whileTrue:[ |
92 runTestCases add:(arguments at:index + 1). |
92 runTestCases add:(arguments at:index + 1). |
93 self logInfo:'run test case: ', (arguments at:index + 1) printString. |
93 self logInfo:'run test: "%1"' with:(arguments at:index + 1). |
94 arguments removeIndex:index + 1. |
94 arguments removeIndex:index + 1. |
95 arguments removeIndex:index. |
95 arguments removeIndex:index. |
96 ]. |
96 ]. |
97 |
97 |
|
98 [ |
|
99 (index := arguments indexOf:'--exclude') > 0 |
|
100 ] whileTrue:[ |
|
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. |
|
105 ]. |
|
106 |
98 index := arguments indexOf:'--forceTestCase'. |
107 index := arguments indexOf:'--forceTestCase'. |
99 index > 0 ifTrue:[ |
108 index > 0 ifTrue:[ |
100 forceTestCase := arguments at:index + 1. |
109 forceTestCase := arguments at:index + 1. |
101 self logInfo:'set force test case: ', forceTestCase printString. |
110 self logInfo:'run single test (forceTestCase): "%1"' with:forceTestCase. |
102 ]. |
111 ]. |
103 |
112 |
104 doRunSpecificUnitTests ifFalse:[ |
113 (doRunSpecificUnitTests not and:[forceTestCase isNil]) ifTrue:[ |
105 self logInfo:'configured to run all available unit tests'. |
114 self logInfo:'configured to run all available unit tests'. |
106 ]. |
115 ]. |
107 |
116 |
108 self logInfo:'collecting unit test classes to run'. |
117 "/ self logInfo:'collecting tests to run'. |
109 unitTestSuite := TestSuite named:unitTestSuiteName. |
118 unitTestSuite := TestSuite named:unitTestSuiteName. |
110 |
119 |
111 (Smalltalk at: #'stx_goodies_regression') classNames do:[:eachClassName | |
120 (Smalltalk at: #'stx_goodies_regression') classNames do:[:eachClassName | |
112 (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ |
121 (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ |
113 self |
122 self logInfo:'exclude test "%1".' with:eachClassName. |
114 logInfo:('excluded unit test class "%1".' |
123 ] ifFalse:[ |
115 bindWith:eachClassName). |
124 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
116 ] ifFalse:[ |
125 self logWarning:'test "%1" is marked as corrupted, please fix' with:eachClassName. |
117 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
126 ] ifFalse:[ |
118 self |
127 (eachClassName notNil |
119 logWarning:('RunUnitTest: unit test class is marked as corrupted, please fix #%1' |
128 and:[ |
120 bindWith:eachClassName). |
129 "/ skip non test class classes |
121 ] ifFalse:[ |
130 (#( |
122 (eachClassName notNil |
131 'stx_goodies_regression' |
123 and:[ |
132 ) includes:eachClassName) not |
124 "/ skip non test case classes |
133 and:[ |
125 (#( |
134 forceTestCase isNil |
126 'stx_goodies_regression' |
135 or:[forceTestCase = eachClassName |
127 ) includes:eachClassName) not |
136 or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] |
128 and:[ |
137 ]]) ifTrue:[ |
129 forceTestCase isNil |
138 eachClass := Smalltalk at:eachClassName. |
130 or:[forceTestCase = eachClassName |
139 |
131 or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] |
140 useCompiledUnitTestClasses ifFalse:[ |
132 ]]) ifTrue:[ |
141 "here we want to test the jitter code |
133 eachClass := Smalltalk at:eachClassName. |
142 therfore we file in, exit if the class is already present somwhow" |
134 |
143 eachClass notNil ifTrue:[ |
135 useCompiledUnitTestClasses ifFalse:[ |
144 self logWarning:'test class "%1" was already present as stc-compiled class before file in.' with:eachClassName. |
136 "here we want test the jitter code |
145 Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
137 therfor we file in, exit if the class is already present somwhow" |
146 Smalltalk exit:1. |
138 eachClass notNil ifTrue:[ |
147 ]. |
139 self |
148 ]. |
140 logWarning:('Unit test class "%1" was already present before file in.' |
149 |
141 bindWith:eachClassName). |
150 eachClass := Smalltalk |
142 |
151 fileInClass:eachClassName |
143 Smalltalk exit:1. |
152 package:'stx:goodies/regression'. |
144 ]. |
153 ]. |
145 |
154 |
146 eachClass := Smalltalk |
155 eachClass notNil ifTrue:[ |
147 fileInClass:eachClassName |
156 (eachClass isTestCaseLike |
148 package:'stx:goodies/regression'. |
157 and:[eachClass isAbstract not]) ifTrue:[ |
149 ]. |
158 self logInfo:'added test "%1".' with:eachClassName. |
150 |
159 unitTestSuite addTest:eachClass suite. |
151 eachClass notNil ifTrue:[ |
160 ] ifFalse:[ |
152 (eachClass isTestCaseLike |
161 self logInfo:'not a test "%1" (abstract or something else).' |
153 and:[eachClass isAbstract not]) ifTrue:[ |
162 with:eachClassName. |
154 self |
163 ]. |
155 logInfo:('added unit test class "%1".' |
164 ] ifFalse:[ |
156 bindWith:eachClassName). |
165 self logWarning:'test class "%1" is not loaded.' with:eachClassName. |
157 |
166 ]. |
158 unitTestSuite addTest:eachClass suite. |
167 ] ifFalse:[ |
159 ] ifFalse:[ |
168 self logInfo:'skipped test "%1".' with:eachClassName. |
160 self |
169 ]. |
161 logInfo:('not a unit test class "%1" (class is abstract or something else).' |
170 ]. |
162 bindWith:eachClassName). |
171 ]. |
163 ]. |
172 ]. |
164 ] ifFalse:[ |
173 |
165 self |
174 self logInfo:'%1 unit test classes collected' with:unitTestSuite tests size. |
166 logWarning:('unit test class "%1" is not loaded.' |
|
167 bindWith:eachClassName). |
|
168 ]. |
|
169 ] ifFalse:[ |
|
170 self |
|
171 logInfo:('skipped unit test class "%1".' |
|
172 bindWith:eachClassName). |
|
173 ]. |
|
174 ]. |
|
175 ]. |
|
176 ]. |
|
177 |
|
178 self |
|
179 logInfo:('%1 unit test classes collected' |
|
180 bindWith:unitTestSuite tests size). |
|
181 |
175 |
182 self logInfo:'start tests...'. |
176 self logInfo:'start tests...'. |
183 result := unitTestSuite |
177 result := unitTestSuite |
184 run:TestResultStX new |
178 run:TestResultStX new |
185 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
179 beforeEachDo:[:test | |
186 afterEachDo:[:test| ] |
180 self logInfo:'performing unit test "%1"' with:test printString |
187 debug:debug. |
181 ] |
|
182 afterEachDo:[:test :result| |
|
183 |execTime status| |
|
184 |
|
185 execTime := result lastOutcome executionTimeDuration. |
|
186 status := result lastOutcome overallOutcome. |
|
187 self logInfo:' Status: %1 (exec. Time: %2)' with:status with:execTime. |
|
188 ] |
|
189 debug:debug. |
188 |
190 |
189 self logInfo:'tests finished.'. |
191 self logInfo:'tests finished.'. |
190 |
192 |
191 self logInfo:'generating xml report...'. |
193 self logInfo:'generating xml report...'. |
192 TestResultReporter |
194 [ |
193 report:result |
195 TestResultReporter |
194 format:#xml_jUnit |
196 report:result |
195 as:resultFilePathName ? 'testresult.xml'. |
197 format:#xml_jUnit |
196 |
198 as:(resultFilePathName ? 'testresult.xml'). |
197 self logInfo:('xml report in %1' bindWith:(resultFilePathName ? 'testresult.xml') asFilename pathName). |
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 ]. |
|
206 |
|
207 self logInfo:'xml report generated in %1' with:(resultFilePathName ? 'testresult.xml') asFilename pathName. |
198 |
208 |
199 self logInfo:'Summary:'. |
209 self logInfo:'Summary:'. |
200 self logInfo:('%1 tests' bindWith:result tests size). |
210 self logInfo:' %1 tests' with:result tests size. |
201 self logInfo:('%1 run' bindWith:result runCount). |
211 self logInfo:' %1 run' with:result runCount. |
202 self logInfo:('%1 skipped' bindWith:result skippedCount). |
212 self logInfo:' %1 skipped' with:result skippedCount. |
203 self logInfo:('%1 passed' bindWith:result passedCount). |
213 self logInfo:' %1 passed' with:result passedCount. |
204 self logInfo:('%1 failed' bindWith:result failureCount). |
214 self logInfo:' %1 failed' with:result failureCount. |
205 self logInfo:('%1 errors' bindWith:result errorCount). |
215 self logInfo:' %1 errors' with:result errorCount. |
|
216 self logInfo:' exec. time: %1' with:(TimeDuration fromSeconds:result executionTime). |
206 |
217 |
207 "Modified (format): / 16-05-2018 / 13:59:47 / sr" |
218 "Modified (format): / 16-05-2018 / 13:59:47 / sr" |
208 "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" |
219 "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" |
209 ! ! |
220 ! ! |
210 |
221 |
266 debug:true |
277 debug:true |
267 ! |
278 ! |
268 |
279 |
269 example2 |
280 example2 |
270 Processor activeProcess exceptionHandlerSet |
281 Processor activeProcess exceptionHandlerSet |
271 on:Class updateChangeFileQuerySignal |
282 on:Class updateChangeFileQuerySignal |
272 do:[:ex | ex proceedWith:false]. |
283 do:[:ex | ex proceedWith:false]. |
273 |
284 |
274 self |
285 self |
275 runWithCompiledUnitTestClasses:true |
286 runWithCompiledUnitTestClasses:true |
276 arguments:#( |
287 arguments:#( |
277 '--forceTestCase' |
288 '--forceTestCase' |
278 'RegressionTests::ExternalStreamTest' |
289 'RegressionTests::ExternalStreamTest' |
279 ) |
290 ) |
280 debug:true |
291 debug:true |
281 |
292 |
282 "Created: / 26-03-2019 / 18:46:46 / Claus Gittinger" |
293 "Created: / 26-03-2019 / 18:46:46 / Claus Gittinger" |
283 ! |
294 ! |
284 |
295 |
285 example2b |
296 example2b |
286 Processor activeProcess exceptionHandlerSet |
297 Processor activeProcess exceptionHandlerSet |
287 on:Class updateChangeFileQuerySignal |
298 on:Class updateChangeFileQuerySignal |
288 do:[:ex | ex proceedWith:false]. |
299 do:[:ex | ex proceedWith:false]. |
289 |
300 |
290 self |
301 self |
291 runWithCompiledUnitTestClasses:true |
302 runWithCompiledUnitTestClasses:true |
292 arguments:#( |
303 arguments:#( |
293 '--forceTestCase' |
304 '--forceTestCase' |
294 'ExternalStreamTest' |
305 'ExternalStreamTest' |
295 ) |
306 ) |
296 debug:true |
307 debug:true |
297 |
308 |
298 "Created: / 26-03-2019 / 18:55:46 / Claus Gittinger" |
309 "Created: / 26-03-2019 / 18:55:46 / Claus Gittinger" |
299 ! |
310 ! |
300 |
311 |
301 example2c |
312 example2c |
302 Processor activeProcess exceptionHandlerSet |
313 Processor activeProcess exceptionHandlerSet |
303 on:Class updateChangeFileQuerySignal |
314 on:Class updateChangeFileQuerySignal |
304 do:[:ex | ex proceedWith:false]. |
315 do:[:ex | ex proceedWith:false]. |
305 |
316 |
306 self |
317 self |
307 runWithCompiledUnitTestClasses:true |
318 runWithCompiledUnitTestClasses:true |
308 arguments:#( |
319 arguments:#( |
309 '--forceTestCase' |
320 '--forceTestCase' |
310 'CRCTests' |
321 'CRCTests' |
311 ) |
322 ) |
312 debug:true |
323 debug:true |
313 |
324 |
314 "Created: / 26-03-2019 / 18:58:36 / Claus Gittinger" |
325 "Created: / 26-03-2019 / 18:58:36 / Claus Gittinger" |
315 ! |
326 ! |
316 |
327 |
317 example3 |
328 example3 |
318 Processor activeProcess exceptionHandlerSet |
329 Processor activeProcess exceptionHandlerSet |
319 on:Class updateChangeFileQuerySignal |
330 on:Class updateChangeFileQuerySignal |
320 do:[:ex | ex proceedWith:false]. |
331 do:[:ex | ex proceedWith:false]. |
321 |
332 |
322 self |
333 self |
323 runWithCompiledUnitTestClasses:true |
334 runWithCompiledUnitTestClasses:true |
324 arguments:#( |
335 arguments:#( |
325 '--run' |
336 '--run' |
326 'ExternalStreamTest' |
337 'ExternalStreamTest' |
327 ) |
338 ) |
328 debug:true |
339 debug:true |
329 |
340 |
330 "Created: / 26-03-2019 / 18:51:42 / Claus Gittinger" |
341 "Created: / 26-03-2019 / 18:51:42 / Claus Gittinger" |
331 ! ! |
342 ! ! |
332 |
343 |
333 !RunUnitTests class methodsFor:'logging'! |
344 !RunUnitTests class methodsFor:'logging'! |
334 |
345 |
335 log:aString type:aType |
346 log:aString type:aType |
336 Transcript notNil ifTrue:[ |
347 Transcript notNil ifTrue:[ |
337 Transcript showCR:'%1 [%2] : %3' |
348 Transcript showCR:'%1 [%2] : %3' |
338 with:Timestamp now printString |
349 with:Timestamp now printString |
339 with:(aType printString asLowercase paddedTo:'warning' size) |
350 with:(aType printString asLowercase paddedTo:'warning' size) |
340 with:aString. |
351 with:aString. |
341 ^ self |
352 ^ self |
342 ]. |
353 ]. |
343 Stderr showCR:'%1 [%2] : %3' |
354 Stderr showCR:'%1 [%2] : %3' |
344 with:Timestamp now printString |
355 with:Timestamp now printString |
345 with:(aType printString asLowercase paddedTo:'warning' size) |
356 with:(aType printString asLowercase paddedTo:'warning' size) |
346 with:aString. |
357 with:aString. |
347 |
358 |
348 "Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger" |
359 "Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger" |
349 ! |
360 ! |
350 |
361 |
351 logInfo:aString |
362 logInfo:aString |
352 self |
363 self log:aString type:'INFO' |
353 log:aString |
364 ! |
354 type:'INFO' |
365 |
|
366 logInfo:aString with:arg |
|
367 self log:(aString bindWith:arg) type:'INFO' |
355 ! |
368 ! |
356 |
369 |
357 logWarning:aString |
370 logWarning:aString |
358 self |
371 self log:aString type:'WARNING' |
359 log:aString |
372 ! |
360 type:'WARNING' |
373 |
|
374 logWarning:aString with:arg |
|
375 self log:(aString bindWith:arg) type:'WARNING' |
361 ! ! |
376 ! ! |
362 |
377 |
363 !RunUnitTests class methodsFor:'documentation'! |
378 !RunUnitTests class methodsFor:'documentation'! |
364 |
379 |
365 version |
380 version |