94 arguments := argumentsIn asOrderedCollection. |
68 arguments := argumentsIn asOrderedCollection. |
95 |
69 |
96 runTestCases := OrderedCollection new. |
70 runTestCases := OrderedCollection new. |
97 doRunSpecificUnitTests := false. |
71 doRunSpecificUnitTests := false. |
98 unitTestSuiteName := 'All Unit Tests'. |
72 unitTestSuiteName := 'All Unit Tests'. |
99 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
73 excludedUnitTestClassNames := self excludedUnitTestClassNames. |
100 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
74 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
101 |
75 |
102 index := arguments indexOf:'--settingsFile'. |
76 index := arguments indexOf:'--settingsFile'. |
103 index > 0 ifTrue:[ |
77 index > 0 ifTrue:[ |
104 settingsFilePathName := arguments at:index + 1. |
78 settingsFilePathName := arguments at:index + 1. |
105 self logInfo:'load settings file: %1' with:settingsFilePathName. |
79 self logInfo:'load settings file: %1' with:settingsFilePathName. |
106 settingsFilePathName asFilename fileIn. |
80 settingsFilePathName asFilename fileIn. |
107 self logInfo:'makeCommand (from ParserFlags) is: %1' with:(ParserFlags makeCommand). |
81 self logInfo:'makeCommand (from ParserFlags) is: %1' with:(ParserFlags makeCommand). |
108 ]. |
82 ]. |
109 |
83 |
110 (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
84 (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
111 self logInfo:'configured to run expecco unit tests only'. |
85 self logInfo:'configured to run expecco unit tests only'. |
112 doRunSpecificUnitTests := true. |
86 doRunSpecificUnitTests := true. |
113 unitTestSuiteName := 'expecco Unit Tests'. |
87 unitTestSuiteName := 'expecco Unit Tests'. |
114 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
88 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
115 ]. |
89 ]. |
116 |
90 |
117 index := arguments indexOf:'--resultFile'. |
91 index := arguments indexOf:'--resultFile'. |
118 index > 0 ifTrue:[ |
92 index > 0 ifTrue:[ |
119 resultFilePathName := arguments at:index + 1. |
93 resultFilePathName := arguments at:index + 1. |
120 self logInfo:'set custom result file: %1' with:resultFilePathName. |
94 self logInfo:'set custom result file: %1' with:resultFilePathName. |
121 ]. |
95 ]. |
122 |
96 |
123 [ |
97 [ |
124 (index := arguments indexOf:'--run') > 0 |
98 (index := arguments indexOf:'--run') > 0 |
125 ] whileTrue:[ |
99 ] whileTrue:[ |
126 runTestCases add:(arguments at:index + 1). |
100 runTestCases add:(arguments at:index + 1). |
127 self logInfo:'run test: "%1"' with:(arguments at:index + 1). |
101 self logInfo:'run test: "%1"' with:(arguments at:index + 1). |
128 arguments removeIndex:index + 1. |
102 arguments removeIndex:index + 1. |
129 arguments removeIndex:index. |
103 arguments removeIndex:index. |
130 ]. |
104 ]. |
131 |
105 |
132 [ |
106 [ |
133 (index := arguments indexOf:'--exclude') > 0 |
107 (index := arguments indexOf:'--exclude') > 0 |
134 ] whileTrue:[ |
108 ] whileTrue:[ |
135 excludedUnitTestClassNames add:(arguments at:index + 1). |
109 excludedUnitTestClassNames add:(arguments at:index + 1). |
136 self logInfo:'exclude test: "%1"' with:(arguments at:index + 1). |
110 self logInfo:'exclude test: "%1"' with:(arguments at:index + 1). |
137 arguments removeIndex:index + 1. |
111 arguments removeIndex:index + 1. |
138 arguments removeIndex:index. |
112 arguments removeIndex:index. |
139 ]. |
113 ]. |
140 |
114 |
141 index := arguments indexOf:'--forceTestCase'. |
115 index := arguments indexOf:'--forceTestCase'. |
142 index > 0 ifTrue:[ |
116 index > 0 ifTrue:[ |
143 forceTestCase := arguments at:index + 1. |
117 forceTestCase := arguments at:index + 1. |
144 self logInfo:'run single test (forceTestCase): "%1"' with:forceTestCase. |
118 self logInfo:'run single test (forceTestCase): "%1"' with:forceTestCase. |
145 ]. |
119 ]. |
146 |
120 |
147 index := arguments indexOf:'--testRunner'. |
121 index := arguments indexOf:'--testRunner'. |
148 index > 0 ifTrue:[ |
122 index > 0 ifTrue:[ |
149 arguments removeIndex:index. |
123 arguments removeIndex:index. |
150 forceTestCase := #'RunUnitTests::RunnerSelfTest'. |
124 forceTestCase := #'RunUnitTests::RunnerSelfTest'. |
151 self logInfo:'execute runner self test'. |
125 self logInfo:'execute runner self test'. |
152 ]. |
126 ]. |
153 |
127 |
154 (doRunSpecificUnitTests not and:[forceTestCase isNil]) ifTrue:[ |
128 (doRunSpecificUnitTests not and:[forceTestCase isNil]) ifTrue:[ |
155 self logInfo:'configured to run all available unit tests'. |
129 self logInfo:'configured to run all available unit tests'. |
156 ]. |
130 ]. |
157 |
131 |
158 "/ self logInfo:'collecting tests to run'. |
132 "/ self logInfo:'collecting tests to run'. |
159 unitTestSuite := TestSuite named:unitTestSuiteName. |
133 unitTestSuite := TestSuite named:unitTestSuiteName. |
160 |
134 |
161 possibleClassNames := (Smalltalk at: #'stx_goodies_regression') classNames. |
135 possibleClassNames := (Smalltalk at: #'stx_goodies_regression') classNames. |
162 possibleClassNames add:#'RunUnitTests::RunnerSelfTest'. |
136 possibleClassNames add:#'RunUnitTests::RunnerSelfTest'. |
163 |
137 |
164 possibleClassNames do:[:eachClassName | |
138 possibleClassNames do:[:eachClassName | |
165 (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ |
139 (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ |
166 self logInfo:'exclude test "%1".' with:eachClassName. |
140 self logInfo:'exclude test "%1".' with:eachClassName. |
167 ] ifFalse:[ |
141 ] ifFalse:[ |
168 (runTestCases notEmptyOrNil and:[(runTestCases includes:eachClassName) not]) ifTrue:[ |
142 (runTestCases notEmptyOrNil and:[(runTestCases includes:eachClassName) not]) ifTrue:[ |
169 self logInfo:'not selected: "%1".' with:eachClassName. |
143 self logInfo:'not selected: "%1".' with:eachClassName. |
170 ] ifFalse:[ |
144 ] ifFalse:[ |
171 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
145 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
172 self logWarning:'test "%1" is marked as corrupted, please fix' with:eachClassName. |
146 self logWarning:'test "%1" is marked as corrupted, please fix' with:eachClassName. |
173 ] ifFalse:[ |
147 ] ifFalse:[ |
174 (eachClassName notNil |
148 (eachClassName notNil |
175 and:[ |
149 and:[ |
176 "/ skip non test class classes |
150 "/ skip non test class classes |
177 (#( |
151 (#( |
178 'stx_goodies_regression' |
152 'stx_goodies_regression' |
179 ) includes:eachClassName) not |
153 ) includes:eachClassName) not |
180 and:[ |
154 and:[ |
181 forceTestCase isNil |
155 forceTestCase isNil |
182 or:[forceTestCase = eachClassName |
156 or:[forceTestCase = eachClassName |
183 or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] |
157 or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] |
184 ]]) ifTrue:[ |
158 ]]) ifTrue:[ |
185 eachClass := Smalltalk at:eachClassName. |
159 eachClass := Smalltalk at:eachClassName. |
186 |
160 |
187 useCompiledUnitTestClasses ifFalse:[ |
161 useCompiledUnitTestClasses ifFalse:[ |
188 "here we want to test the jitter code |
162 "here we want to test the jitter code |
189 therfore we file in, exit if the class is already present somwhow" |
163 therfore we file in, exit if the class is already present somwhow" |
190 eachClass notNil ifTrue:[ |
164 eachClass notNil ifTrue:[ |
191 self logWarning:'test class "%1" was already present as stc-compiled class before file in.' with:eachClassName. |
165 self logWarning:'test class "%1" was already present as stc-compiled class before file in.' with:eachClassName. |
192 Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
166 Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
193 Smalltalk exit:1. |
167 Smalltalk exit:1. |
194 ]. |
168 ]. |
195 ]. |
169 ]. |
196 |
170 |
197 eachClass := Smalltalk |
171 eachClass := Smalltalk |
198 fileInClass:eachClassName |
172 fileInClass:eachClassName |
199 package:'stx:goodies/regression'. |
173 package:'stx:goodies/regression'. |
200 ]. |
174 ]. |
201 |
175 |
202 eachClass notNil ifTrue:[ |
176 eachClass notNil ifTrue:[ |
203 (eachClass isTestCaseLike |
177 (eachClass isTestCaseLike |
204 and:[eachClass isAbstract not]) ifTrue:[ |
178 and:[eachClass isAbstract not]) ifTrue:[ |
205 self logInfo:'added test "%1".' with:eachClassName. |
179 self logInfo:'added test "%1".' with:eachClassName. |
206 unitTestSuite addTest:eachClass suite. |
180 unitTestSuite addTest:eachClass suite. |
207 ] ifFalse:[ |
181 ] ifFalse:[ |
208 self logInfo:'not a test "%1" (abstract or something else).' |
182 self logInfo:'not a test "%1" (abstract or something else).' |
209 with:eachClassName. |
183 with:eachClassName. |
210 ]. |
184 ]. |
211 ] ifFalse:[ |
185 ] ifFalse:[ |
212 self logWarning:'test class "%1" is not loaded.' with:eachClassName. |
186 self logWarning:'test class "%1" is not loaded.' with:eachClassName. |
213 ]. |
187 ]. |
214 ] ifFalse:[ |
188 ] ifFalse:[ |
215 self logInfo:'skipped test "%1".' with:eachClassName. |
189 self logInfo:'skipped test "%1".' with:eachClassName. |
216 ]. |
190 ]. |
217 ]. |
191 ]. |
218 ]. |
192 ]. |
219 ]. |
193 ]. |
220 ]. |
194 ]. |
221 |
195 |
222 self logInfo:'%1 unit test(s) collected' with:(unitTestSuite tests size). |
196 self logInfo:'%1 unit test(s) collected' with:(unitTestSuite tests size). |
223 |
197 |
224 self logInfo:'start tests...'. |
198 self logInfo:'start tests...'. |
225 [ |
199 [ |
226 result := |
200 result := |
227 unitTestSuite |
201 unitTestSuite |
228 run:TestResultStX new |
202 run:TestResultStX new |
229 beforeEachDo:[:test | |
203 beforeEachDo:[:test | |
230 self logInfo:'Run "%1"' with:test printString |
204 self logInfo:'Run "%1"' with:test printString |
231 ] |
205 ] |
232 afterEachDo:[:test :result| |
206 afterEachDo:[:test :result| |
233 |execTime status| |
207 |execTime status| |
234 |
208 |
235 execTime := result lastOutcome executionTimeDuration. |
209 execTime := result lastOutcome executionTimeDuration. |
236 status := result lastOutcome result. |
210 status := result lastOutcome result. |
237 self logInfo:' %1 (%2)' with:status with:execTime. |
211 self logInfo:' %1 (%2)' with:status with:execTime. |
238 (status == TestResult stateFail or:[status == TestResult stateError]) ifTrue:[ |
212 (status == TestResult stateFail or:[status == TestResult stateError]) ifTrue:[ |
239 self logInfo:' ==================='. |
213 self logInfo:' ==================='. |
240 ] |
214 ] |
241 ] |
215 ] |
242 debug:debug. |
216 debug:debug. |
243 ] ifCurtailed:[ |
217 ] ifCurtailed:[ |
244 self logWarning:'aborted in:.'. |
218 self logWarning:'aborted in:.'. |
245 thisContext fullPrintAllOn:Stderr. |
219 thisContext fullPrintAllOn:Stderr. |
246 ]. |
220 ]. |
247 |
221 |
248 self logInfo:'tests finished.'. |
222 self logInfo:'tests finished.'. |
249 |
223 |
250 self logInfo:'generating xml report...'. |
224 self logInfo:'generating xml report...'. |
251 [ |
225 [ |
252 TestResultReporter |
226 TestResultReporter |
253 report:result |
227 report:result |
254 format:#xml_jUnit |
228 format:#xml_jUnit |
255 as:(resultFilePathName ? 'testresult.xml'). |
229 as:(resultFilePathName ? 'testresult.xml'). |
256 ] on:Error do:[:ex | |
230 ] on:Error do:[:ex | |
257 self logWarning:'error while generating xml report: %1' with:ex description. |
231 self logWarning:'error while generating xml report: %1' with:ex description. |
258 self logWarning:'in: %1' with:(ex suspendedContext fullPrintAllString). |
232 self logWarning:'in: %1' with:(ex suspendedContext fullPrintAllString). |
259 Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
233 Smalltalk isSmalltalkDevelopmentSystem ifFalse:[ |
260 Smalltalk exit:1. |
234 Smalltalk exit:1. |
261 ]. |
235 ]. |
262 ]. |
236 ]. |
263 |
237 |
264 self logInfo:'xml report generated in %1' with:(resultFilePathName ? 'testresult.xml') asFilename pathName. |
238 self logInfo:'xml report generated in %1' with:(resultFilePathName ? 'testresult.xml') asFilename pathName. |
265 |
239 |
266 self logInfo:'Summary:'. |
240 self logInfo:'Summary:'. |
267 self logInfo:(' %1 tests, %2 run (%3 skipped) / %4 passed, %5 failed, %6 errors' |
241 self logInfo:(' %1 tests, %2 run (%3 skipped) / %4 passed, %5 failed, %6 errors' |
268 bindWith:result tests size |
242 bindWith:result tests size |
269 with:result runCount |
243 with:result runCount |
270 with:result skippedCount |
244 with:result skippedCount |
271 with:result passedCount |
245 with:result passedCount |
272 with:result failureCount |
246 with:result failureCount |
273 with:result errorCount). |
247 with:result errorCount). |
274 "/ self logInfo:' exec. time: %1' with:(TimeDuration fromSeconds:result executionTime). |
248 "/ self logInfo:' exec. time: %1' with:(TimeDuration fromSeconds:result executionTime). |
275 |
249 |
276 "Modified (format): / 16-05-2018 / 13:59:47 / sr" |
250 "Modified (format): / 16-05-2018 / 13:59:47 / sr" |
277 "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" |
251 "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" |
|
252 "Modified: / 06-06-2019 / 10:02:52 / Stefan Reise" |
278 ! ! |
253 ! ! |
279 |
254 |
280 !RunUnitTests class methodsFor:'constants'! |
255 !RunUnitTests class methodsFor:'constants'! |
281 |
256 |
282 corruptedUnitTestClassNames |
257 corruptedUnitTestClassNames |
285 #'RegressionTests::DebuggerTest' |
260 #'RegressionTests::DebuggerTest' |
286 #'RegressionTests::ContextTest2' |
261 #'RegressionTests::ContextTest2' |
287 ) |
262 ) |
288 ! |
263 ! |
289 |
264 |
290 excludedUnitTestClassNamesForAll |
265 excludedUnitTestClassNames |
291 ^ #( |
266 |collection| |
292 #'RegressionTests::SelectorNamespacesTests' |
267 |
293 ) |
268 collection := OrderedCollection new. |
|
269 collection add:#'RegressionTests::SelectorNamespacesTests'. |
|
270 |
|
271 "now exclude architecture dependent stuff" |
|
272 (OperatingSystem isMSWINDOWSlike not |
|
273 or:[ExternalAddress pointerSize = 8]) ifTrue:[ |
|
274 collection add:#'RegressionTests::Win32OLETests'. |
|
275 ]. |
|
276 |
|
277 ^ collection |
|
278 |
|
279 "Created: / 06-06-2019 / 10:02:46 / Stefan Reise" |
294 ! |
280 ! |
295 |
281 |
296 excludedUnitTestClassNamesForExpecco |
282 excludedUnitTestClassNamesForExpecco |
297 ^ self excludedUnitTestClassNamesForAll |
283 ^ self excludedUnitTestClassNames |
298 , #( |
284 , #( |
299 #'RegressionTests::VMCrashTestCase' |
285 #'RegressionTests::VMCrashTestCase' |
300 #'RegressionTests::VMCrashTests' |
286 #'RegressionTests::VMCrashTests' |
301 #'RegressionTests::ParserTests' |
287 #'RegressionTests::ParserTests' |
302 #'RegressionTests::BreakpointTests' |
288 #'RegressionTests::BreakpointTests' |
303 #'RegressionTests::SunitXMLOutputTest' |
289 #'RegressionTests::SunitXMLOutputTest' |
304 #'RegressionTests::CompilerTests2' |
290 #'RegressionTests::CompilerTests2' |
305 #'RegressionTests::BehaviorLookupObjectTests' |
291 #'RegressionTests::BehaviorLookupObjectTests' |
306 #'RegressionTests::ChangeSetTests' |
292 #'RegressionTests::ChangeSetTests' |
307 #'RegressionTests::MakefileTests' |
293 #'RegressionTests::MakefileTests' |
308 #'RegressionTests::MetaphoneStringComparatorTest' |
294 #'RegressionTests::MetaphoneStringComparatorTest' |
309 #'RegressionTests::STCCompilerTests' |
295 #'RegressionTests::STCCompilerTests' |
310 #'RegressionTests::VMCrashTests' |
296 #'RegressionTests::VMCrashTests' |
311 #'RegressionTests::SnapshotRestartTests' |
297 #'RegressionTests::SnapshotRestartTests' |
312 #'RegressionTests::GraphicDrawingTest' |
298 #'RegressionTests::GraphicDrawingTest' |
313 #'RegressionTests::OS_OLE_Tests' |
299 #'RegressionTests::OS_OLE_Tests' |
314 #'RegressionTests::ExternalInterfaceTests' |
300 #'RegressionTests::ExternalInterfaceTests' |
315 #'RegressionTests::DebuggerTest' |
301 #'RegressionTests::DebuggerTest' |
316 #'RegressionTests::ContextTest2' |
302 #'RegressionTests::ContextTest2' |
317 #'RegressionTests::QDoubleTests' |
303 #'RegressionTests::QDoubleTests' |
318 ) |
304 ) |
|
305 |
|
306 "Modified: / 06-06-2019 / 10:02:54 / Stefan Reise" |
319 ! ! |
307 ! ! |
320 |
308 |
321 !RunUnitTests class methodsFor:'examples'! |
309 !RunUnitTests class methodsFor:'examples'! |
322 |
310 |
323 example1 |
311 example1 |