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