sr@447: "{ Encoding: utf8 }" sr@447: sr@349: "{ Package: 'stx:goodies/builder/quickSelfTest' }" sr@329: sr@329: "{ NameSpace: Smalltalk }" sr@329: sr@329: Object subclass:#RunUnitTests sr@329: instanceVariableNames:'' sr@329: classVariableNames:'' sr@329: poolDictionaries:'' sr@329: category:'tests-Regression' sr@329: ! sr@329: sr@329: !RunUnitTests class methodsFor:'documentation'! sr@329: sr@329: documentation sr@329: " cg@538: typically invoked by RunUnitTestsStart sr@329: sr@329: [author:] cg@538: sr sr@329: sr@329: [instance variables:] sr@329: sr@329: [class variables:] sr@329: sr@329: [see also:] sr@329: sr@329: " sr@329: ! ! sr@329: sr@329: !RunUnitTests class methodsFor:'actions'! sr@329: sr@329: run sr@400: self runWithCompiledUnitTestClasses:false. sr@398: ! sr@398: sr@398: runWithCompiledUnitTestClasses:useCompiledUnitTestClasses sr@426: |cmdArgs| sr@426: sr@426: cmdArgs := Smalltalk commandLineArguments. sv@514: sv@514: self sv@514: runWithCompiledUnitTestClasses:useCompiledUnitTestClasses sv@514: arguments:cmdArgs sv@514: debug:(cmdArgs includes:'--debug') sr@426: ! sr@426: sr@426: runWithCompiledUnitTestClasses:useCompiledUnitTestClasses cg@538: arguments:argumentsIn sr@426: debug:debug sr@426: cg@538: |arguments cg@538: doRunSpecificUnitTests unitTestSuiteName excludedUnitTestClassNames corruptedUnitTestClassNames sr@398: unitTestSuite sr@427: eachClass sr@419: result index cg@538: settingsFilePathName resultFilePathName forceTestCase runTestCases| sr@398: cg@538: arguments := argumentsIn asOrderedCollection. cg@538: cg@538: runTestCases := OrderedCollection new. sr@398: doRunSpecificUnitTests := false. sr@398: unitTestSuiteName := 'All Unit Tests'. sr@398: excludedUnitTestClassNames := self excludedUnitTestClassNamesForAll. sr@398: corruptedUnitTestClassNames := self corruptedUnitTestClassNames. sr@398: sr@447: index := arguments indexOf:'--settingsFile'. sr@398: index > 0 ifTrue:[ sr@515: settingsFilePathName := arguments at:index + 1. sr@515: self logInfo:'load settings file: ', settingsFilePathName printString. sr@515: settingsFilePathName asFilename fileIn. sr@515: self logInfo:'ParserFlags makeCommand: ', ParserFlags makeCommand printString. sr@418: ]. sr@418: sr@447: (arguments includes:'--runOnlyExpeccoUnitTests') ifTrue:[ sr@515: self logInfo:'configured to run expecco unit tests only'. sr@515: doRunSpecificUnitTests := true. sr@515: unitTestSuiteName := 'expecco Unit Tests'. sr@515: excludedUnitTestClassNames := self excludedUnitTestClassNamesForExpecco. sr@398: ]. sr@398: sr@447: index := arguments indexOf:'--resultFile'. sr@413: index > 0 ifTrue:[ sr@515: resultFilePathName := arguments at:index + 1. sr@515: self logInfo:'set custom result file: ', resultFilePathName printString. sr@413: ]. sr@413: cg@538: [ cg@538: (index := arguments indexOf:'--run') > 0 cg@538: ] whileTrue:[ cg@538: runTestCases add:(arguments at:index + 1). cg@538: self logInfo:'run test case: ', (arguments at:index + 1) printString. cg@538: arguments removeIndex:index + 1. cg@538: arguments removeIndex:index. cg@538: ]. cg@538: sr@447: index := arguments indexOf:'--forceTestCase'. sr@418: index > 0 ifTrue:[ sr@515: forceTestCase := arguments at:index + 1. sr@515: self logInfo:'set force test case: ', forceTestCase printString. sr@419: ]. sr@398: sr@398: doRunSpecificUnitTests ifFalse:[ sr@515: self logInfo:'configured to run all available unit tests'. sr@398: ]. sr@398: sr@398: self logInfo:'collecting unit test classes to run'. sr@398: unitTestSuite := TestSuite named:unitTestSuiteName. sr@398: sr@427: (Smalltalk at: #'stx_goodies_regression') classNames do:[:eachClassName | sr@515: (excludedUnitTestClassNames includes:eachClassName) ifTrue:[ sr@515: self sr@515: logInfo:('excluded unit test class "%1".' sr@515: bindWith:eachClassName). sr@515: ] ifFalse:[ sr@515: (corruptedUnitTestClassNames includes:eachClassName) ifTrue:[ sr@515: self sr@515: logWarning:('RunUnitTest: unit test class is marked as corrupted, please fix #%1' sr@515: bindWith:eachClassName). sr@515: ] ifFalse:[ sr@515: (eachClassName notNil sr@515: and:[ sr@515: "/ skip non test case classes sr@515: (#( sr@515: 'stx_goodies_regression' sr@515: ) includes:eachClassName) not sr@515: and:[ sr@515: forceTestCase isNil sr@515: or:[forceTestCase = eachClassName sr@515: or:[forceTestCase = ((eachClassName subStrings:'::') lastIfEmpty:nil)]] sr@515: ]]) ifTrue:[ sr@515: eachClass := Smalltalk at:eachClassName. sr@407: sr@515: useCompiledUnitTestClasses ifFalse:[ sr@515: "here we want test the jitter code sr@515: therfor we file in, exit if the class is already present somwhow" sr@515: eachClass notNil ifTrue:[ sr@515: self sr@515: logWarning:('Unit test class "%1" was already present before file in.' sr@515: bindWith:eachClassName). sr@407: sr@515: Smalltalk exit:1. sr@515: ]. sr@407: sr@515: eachClass := Smalltalk sr@515: fileInClass:eachClassName sr@515: package:'stx:goodies/regression'. sr@515: ]. sr@398: sr@515: eachClass notNil ifTrue:[ sr@515: (eachClass isTestCaseLike sr@515: and:[eachClass isAbstract not]) ifTrue:[ sr@515: self sr@515: logInfo:('added unit test class "%1".' sr@515: bindWith:eachClassName). sr@422: sr@515: unitTestSuite addTest:eachClass suite. sr@515: ] ifFalse:[ sr@515: self sr@515: logInfo:('not a unit test class "%1" (class is abstract or something else).' sr@515: bindWith:eachClassName). sr@515: ]. sr@515: ] ifFalse:[ sr@515: self sr@515: logWarning:('unit test class "%1" is not loaded.' sr@515: bindWith:eachClassName). sr@515: ]. sr@515: ] ifFalse:[ sr@515: self sr@515: logInfo:('skipped unit test class "%1".' sr@515: bindWith:eachClassName). sr@515: ]. sr@515: ]. sr@515: ]. sr@398: ]. sr@398: sr@398: self sr@515: logInfo:('%1 unit test classes collected' sr@515: bindWith:unitTestSuite tests size). sr@398: cg@538: self logInfo:'start tests...'. sr@398: result := unitTestSuite sr@515: run:TestResultStX new sr@515: beforeEachDo:[:test | self logInfo:'performing unit test ', test printString] sr@515: afterEachDo:[:test| ] sr@515: debug:debug. sr@398: cg@538: self logInfo:'tests finished.'. cg@538: cg@538: self logInfo:'generating xml report...'. sr@398: TestResultReporter sr@515: report:result sr@515: format:#xml_jUnit sr@515: as:resultFilePathName ? 'testresult.xml'. sr@398: cg@538: self logInfo:('xml report in %1' bindWith:(resultFilePathName ? 'testresult.xml') asFilename pathName). cg@538: cg@538: self logInfo:'Summary:'. cg@538: self logInfo:('%1 tests' bindWith:result tests size). cg@538: self logInfo:('%1 run' bindWith:result runCount). cg@538: self logInfo:('%1 skipped' bindWith:result skippedCount). sr@398: self logInfo:('%1 passed' bindWith:result passedCount). sr@398: self logInfo:('%1 failed' bindWith:result failureCount). sr@398: self logInfo:('%1 errors' bindWith:result errorCount). sr@515: sr@515: "Modified (format): / 16-05-2018 / 13:59:47 / sr" cg@538: "Modified: / 26-03-2019 / 19:00:38 / Claus Gittinger" sr@329: ! ! sr@329: sr@329: !RunUnitTests class methodsFor:'constants'! sr@329: sr@329: corruptedUnitTestClassNames sr@329: ^ #( sr@336: #'RegressionTests::ExternalInterfaceTests' sr@336: #'RegressionTests::DebuggerTest' sr@345: #'RegressionTests::ContextTest2' sr@329: ) sr@329: ! sr@329: sr@329: excludedUnitTestClassNamesForAll sr@419: ^ #( sr@419: #'RegressionTests::SelectorNamespacesTests' sr@419: ) sr@329: ! sr@329: sr@336: excludedUnitTestClassNamesForExpecco sr@329: ^ self excludedUnitTestClassNamesForAll sr@410: , #( sr@424: #'RegressionTests::VMCrashTestCase' sr@419: #'RegressionTests::VMCrashTests' sr@420: #'RegressionTests::ParserTests' sr@410: #'RegressionTests::BreakpointTests' sr@410: #'RegressionTests::SunitXMLOutputTest' sr@410: #'RegressionTests::CompilerTests2' sr@410: #'RegressionTests::BehaviorLookupObjectTests' sr@410: #'RegressionTests::ChangeSetTests' sr@410: #'RegressionTests::MakefileTests' sr@410: #'RegressionTests::MetaphoneStringComparatorTest' sr@410: #'RegressionTests::STCCompilerTests' sr@410: #'RegressionTests::VMCrashTests' sr@410: #'RegressionTests::SnapshotRestartTests' sr@410: #'RegressionTests::GraphicDrawingTest' sr@410: #'RegressionTests::OS_OLE_Tests' sr@410: #'RegressionTests::ExternalInterfaceTests' sr@410: #'RegressionTests::DebuggerTest' sr@410: #'RegressionTests::ContextTest2' sr@415: #'RegressionTests::QDoubleTests' sr@410: ) sr@329: ! ! sr@329: sr@428: !RunUnitTests class methodsFor:'examples'! sr@428: sr@428: example1 sr@428: Processor activeProcess exceptionHandlerSet sv@514: on:Class updateChangeFileQuerySignal sv@514: do:[:ex | ex proceedWith:false]. sr@428: sr@428: self sv@514: runWithCompiledUnitTestClasses:true sv@514: arguments:#( sv@514: '--runOnlyExpeccoUnitTests' sv@514: '--forceTestCase' sv@514: 'ExternalStreamTest' sv@514: ) sv@514: debug:true cg@538: ! cg@538: cg@538: example2 cg@538: Processor activeProcess exceptionHandlerSet cg@538: on:Class updateChangeFileQuerySignal cg@538: do:[:ex | ex proceedWith:false]. cg@538: cg@538: self cg@538: runWithCompiledUnitTestClasses:true cg@538: arguments:#( cg@538: '--forceTestCase' cg@538: 'RegressionTests::ExternalStreamTest' cg@538: ) cg@538: debug:true cg@538: cg@538: "Created: / 26-03-2019 / 18:46:46 / Claus Gittinger" cg@538: ! cg@538: cg@538: example2b cg@538: Processor activeProcess exceptionHandlerSet cg@538: on:Class updateChangeFileQuerySignal cg@538: do:[:ex | ex proceedWith:false]. cg@538: cg@538: self cg@538: runWithCompiledUnitTestClasses:true cg@538: arguments:#( cg@538: '--forceTestCase' cg@538: 'ExternalStreamTest' cg@538: ) cg@538: debug:true cg@538: cg@538: "Created: / 26-03-2019 / 18:55:46 / Claus Gittinger" cg@538: ! cg@538: cg@538: example2c cg@538: Processor activeProcess exceptionHandlerSet cg@538: on:Class updateChangeFileQuerySignal cg@538: do:[:ex | ex proceedWith:false]. cg@538: cg@538: self cg@538: runWithCompiledUnitTestClasses:true cg@538: arguments:#( cg@538: '--forceTestCase' cg@538: 'CRCTests' cg@538: ) cg@538: debug:true cg@538: cg@538: "Created: / 26-03-2019 / 18:58:36 / Claus Gittinger" cg@538: ! cg@538: cg@538: example3 cg@538: Processor activeProcess exceptionHandlerSet cg@538: on:Class updateChangeFileQuerySignal cg@538: do:[:ex | ex proceedWith:false]. cg@538: cg@538: self cg@538: runWithCompiledUnitTestClasses:true cg@538: arguments:#( cg@538: '--run' cg@538: 'ExternalStreamTest' cg@538: ) cg@538: debug:true cg@538: cg@538: "Created: / 26-03-2019 / 18:51:42 / Claus Gittinger" sr@428: ! ! sr@428: sr@329: !RunUnitTests class methodsFor:'logging'! sr@329: cg@538: log:aString type:aType cg@538: Transcript notNil ifTrue:[ cg@538: Transcript showCR:'%1 [%2] : %3' cg@538: with:Timestamp now printString cg@538: with:(aType printString asLowercase paddedTo:'warning' size) cg@538: with:aString. cg@538: ^ self cg@538: ]. cg@538: Stderr showCR:'%1 [%2] : %3' cg@538: with:Timestamp now printString cg@538: with:(aType printString asLowercase paddedTo:'warning' size) cg@538: with:aString. sr@329: cg@538: "Modified: / 26-03-2019 / 18:53:48 / Claus Gittinger" sr@329: ! sr@329: sr@329: logInfo:aString sr@329: self sr@336: log:aString sr@336: type:'INFO' sr@329: ! sr@329: sr@329: logWarning:aString sr@329: self sr@336: log:aString sr@336: type:'WARNING' sr@329: ! ! sr@349: sr@349: !RunUnitTests class methodsFor:'documentation'! sr@349: sr@399: version sr@399: ^ '$Header$' sr@399: ! sr@399: sr@349: version_CVS sr@349: ^ '$Header$' sr@349: ! ! sr@515: