61 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
61 excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. |
62 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
62 corruptedUnitTestClassNames := self corruptedUnitTestClassNames. |
63 |
63 |
64 index := arguments indexOf:'--settingsFile'. |
64 index := arguments indexOf:'--settingsFile'. |
65 index > 0 ifTrue:[ |
65 index > 0 ifTrue:[ |
66 settingsFilePathName := arguments at:index + 1. |
66 settingsFilePathName := arguments at:index + 1. |
67 self logInfo:'load settings file: ', settingsFilePathName printString. |
67 self logInfo:'load settings file: ', settingsFilePathName printString. |
68 settingsFilePathName asFilename fileIn. |
68 settingsFilePathName asFilename fileIn. |
69 self logInfo:'ParserFlags makeCommand: ', ParserFlags makeCommand printString. |
69 self logInfo:'ParserFlags makeCommand: ', ParserFlags makeCommand printString. |
70 ]. |
70 ]. |
71 |
71 |
72 (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
72 (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ |
73 self logInfo:'configured to run expecco unit tests only'. |
73 self logInfo:'configured to run expecco unit tests only'. |
74 doRunSpecificUnitTests := true. |
74 doRunSpecificUnitTests := true. |
75 unitTestSuiteName := 'expecco Unit Tests'. |
75 unitTestSuiteName := 'expecco Unit Tests'. |
76 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
76 excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. |
77 ]. |
77 ]. |
78 |
78 |
79 index := arguments indexOf:'--resultFile'. |
79 index := arguments indexOf:'--resultFile'. |
80 index > 0 ifTrue:[ |
80 index > 0 ifTrue:[ |
81 resultFilePathName := arguments at:index + 1. |
81 resultFilePathName := arguments at:index + 1. |
82 self logInfo:'set custom result file: ', resultFilePathName printString. |
82 self logInfo:'set custom result file: ', resultFilePathName printString. |
83 ]. |
83 ]. |
84 |
84 |
85 index := arguments indexOf:'--forceTestCase'. |
85 index := arguments indexOf:'--forceTestCase'. |
86 index > 0 ifTrue:[ |
86 index > 0 ifTrue:[ |
87 forceTestCase := arguments at:index + 1. |
87 forceTestCase := arguments at:index + 1. |
88 self logInfo:'set force test case: ', forceTestCase printString. |
88 self logInfo:'set force test case: ', forceTestCase printString. |
89 ]. |
89 ]. |
90 |
90 |
91 doRunSpecificUnitTests ifFalse:[ |
91 doRunSpecificUnitTests ifFalse:[ |
92 self logInfo:'configured to run all available unit tests'. |
92 self logInfo:'configured to run all available unit tests'. |
93 ]. |
93 ]. |
94 |
94 |
95 self logInfo:'collecting unit test classes to run'. |
95 self logInfo:'collecting unit test classes to run'. |
96 unitTestSuite := TestSuite named:unitTestSuiteName. |
96 unitTestSuite := TestSuite named:unitTestSuiteName. |
97 |
97 |
98 (Smalltalk at: #'stx_goodies_regression') classNames do:[:eachClassName | |
98 (Smalltalk at: #'stx_goodies_regression') classNames do:[:eachClassName | |
99 (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ |
99 (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ |
100 self |
100 self |
101 logInfo:('excluded unit test class "%1".' |
101 logInfo:('excluded unit test class "%1".' |
102 bindWith:eachClassName). |
102 bindWith:eachClassName). |
103 ] ifFalse:[ |
103 ] ifFalse:[ |
104 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
104 (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ |
105 self |
105 self |
106 logWarning:('corrupted unit test class detected, please fix #%1' |
106 logWarning:('RunUnitTest: unit test class is marked as corrupted, please fix #%1' |
107 bindWith:eachClassName). |
107 bindWith:eachClassName). |
108 ] ifFalse:[ |
108 ] ifFalse:[ |
109 (eachClassName notNil |
109 (eachClassName notNil |
110 and:[ |
110 and:[ |
111 "/ skip non test case classes |
111 "/ skip non test case classes |
112 (#( |
112 (#( |
113 'stx_goodies_regression' |
113 'stx_goodies_regression' |
114 ) includes:eachClassName) not |
114 ) includes:eachClassName) not |
115 and:[ |
115 and:[ |
116 forceTestCase isNil |
116 forceTestCase isNil |
117 or:[forceTestCase = eachClassName |
117 or:[forceTestCase = eachClassName |
118 or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] |
118 or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] |
119 ]]) ifTrue:[ |
119 ]]) ifTrue:[ |
120 eachClass := Smalltalk at:eachClassName. |
120 eachClass := Smalltalk at:eachClassName. |
121 |
121 |
122 useCompiledUnitTestClasses ifFalse:[ |
122 useCompiledUnitTestClasses ifFalse:[ |
123 "here we want test the jitter code |
123 "here we want test the jitter code |
124 therfor we file in, exit if the class is already present somwhow" |
124 therfor we file in, exit if the class is already present somwhow" |
125 eachClass notNil ifTrue:[ |
125 eachClass notNil ifTrue:[ |
126 self |
126 self |
127 logWarning:('Unit test class "%1" was already present before file in.' |
127 logWarning:('Unit test class "%1" was already present before file in.' |
128 bindWith:eachClassName). |
128 bindWith:eachClassName). |
129 |
129 |
130 Smalltalk exit:1. |
130 Smalltalk exit:1. |
131 ]. |
131 ]. |
132 |
132 |
133 eachClass := Smalltalk |
133 eachClass := Smalltalk |
134 fileInClass:eachClassName |
134 fileInClass:eachClassName |
135 package:'stx:goodies/regression'. |
135 package:'stx:goodies/regression'. |
136 ]. |
136 ]. |
137 |
137 |
138 eachClass notNil ifTrue:[ |
138 eachClass notNil ifTrue:[ |
139 (eachClass isTestCaseLike |
139 (eachClass isTestCaseLike |
140 and:[eachClass isAbstract not]) ifTrue:[ |
140 and:[eachClass isAbstract not]) ifTrue:[ |
141 self |
141 self |
142 logInfo:('added unit test class "%1".' |
142 logInfo:('added unit test class "%1".' |
143 bindWith:eachClassName). |
143 bindWith:eachClassName). |
144 |
144 |
145 unitTestSuite addTest:eachClass suite. |
145 unitTestSuite addTest:eachClass suite. |
146 ] ifFalse:[ |
146 ] ifFalse:[ |
147 self |
147 self |
148 logInfo:('not a unit test class "%1" (class is abstract or something else).' |
148 logInfo:('not a unit test class "%1" (class is abstract or something else).' |
149 bindWith:eachClassName). |
149 bindWith:eachClassName). |
150 ]. |
150 ]. |
151 ] ifFalse:[ |
151 ] ifFalse:[ |
152 self |
152 self |
153 logWarning:('unit test class "%1" is not loaded.' |
153 logWarning:('unit test class "%1" is not loaded.' |
154 bindWith:eachClassName). |
154 bindWith:eachClassName). |
155 ]. |
155 ]. |
156 ] ifFalse:[ |
156 ] ifFalse:[ |
157 self |
157 self |
158 logInfo:('skipped unit test class "%1".' |
158 logInfo:('skipped unit test class "%1".' |
159 bindWith:eachClassName). |
159 bindWith:eachClassName). |
160 ]. |
160 ]. |
161 ]. |
161 ]. |
162 ]. |
162 ]. |
163 ]. |
163 ]. |
164 |
164 |
165 self |
165 self |
166 logInfo:('%1 unit test classes collected' |
166 logInfo:('%1 unit test classes collected' |
167 bindWith:unitTestSuite tests size). |
167 bindWith:unitTestSuite tests size). |
168 |
168 |
169 self logInfo:'starting unit tests'. |
169 self logInfo:'starting unit tests'. |
170 result := unitTestSuite |
170 result := unitTestSuite |
171 run:TestResultStX new |
171 run:TestResultStX new |
172 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
172 beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] |
173 afterEachDo:[:test| ] |
173 afterEachDo:[:test| ] |
174 debug:debug. |
174 debug:debug. |
175 |
175 |
176 self logInfo:'generating report'. |
176 self logInfo:'generating report'. |
177 TestResultReporter |
177 TestResultReporter |
178 report:result |
178 report:result |
179 format:#xml_jUnit |
179 format:#xml_jUnit |
180 as:resultFilePathName ? 'testresult.xml'. |
180 as:resultFilePathName ? 'testresult.xml'. |
181 |
181 |
182 self logInfo:'summary:'. |
182 self logInfo:'summary:'. |
183 self logInfo:('%1 tests' bindWith:result runCount). |
183 self logInfo:('%1 tests' bindWith:result runCount). |
184 self logInfo:('%1 passed' bindWith:result passedCount). |
184 self logInfo:('%1 passed' bindWith:result passedCount). |
185 self logInfo:('%1 failed' bindWith:result failureCount). |
185 self logInfo:('%1 failed' bindWith:result failureCount). |