RegressionTests__QuickTestRunner.st
changeset 717 491ebbb9a7aa
child 769 b660307de1b1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RegressionTests__QuickTestRunner.st	Wed Oct 31 14:04:39 2012 +0100
@@ -0,0 +1,217 @@
+"{ Package: 'exept:regression' }"
+
+"{ NameSpace: RegressionTests }"
+
+Object subclass:#QuickTestRunner
+	instanceVariableNames:'suite anyError result'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'tests-Regression'
+!
+
+!QuickTestRunner class methodsFor:'documentation'!
+
+documentation
+"
+    ATTENTION: if you change anything here, please verify compatibility with the
+               SeltTestRunner script found in exept/regression.
+
+    This is meant to be called via a script or command-line argument, when executing
+    selftests via jenkins.
+
+    Runs a number of tests from the exept:regression package (see list below)
+    executed through SelfTestRunner script using the following command line:
+
+    stx --noBanner -I --execute SelfTestRunner.st
+      use --debug to debug failed test cases.
+
+    to use with jenkins (+ jUnit plugin):
+    use the following buildscript (in jenkins):
+    (after checkout of stx)
+         cd stx
+         call bmake
+         cd goodies\selftest
+         ..\..\projects\smalltalk\stx.com --noBanner -I --execute SelfTestRunner.st
+
+    and configure the jenkins junit plugin, to scan for 'testresult.xml'
+
+    [author:]
+        Claus Gittinger
+
+    [instance variables:]
+
+    [class variables:]
+
+    [see also:]
+
+"
+! !
+
+!QuickTestRunner class methodsFor:'instance creation'!
+
+new
+    "return an initialized instance"
+
+    ^ self basicNew initialize.
+! !
+
+!QuickTestRunner class methodsFor:'execution'!
+
+start
+    |runner|
+
+    runner := self new.
+    runner
+        prepare;
+        buildSuite;
+        runSuite.
+
+    Smalltalk isStandAloneApp ifTrue:[
+        Smalltalk exit:(runner anyError ifTrue:[1] ifFalse:[0])
+    ].
+! !
+
+!QuickTestRunner methodsFor:'execution'!
+
+buildSuite
+    |anyMissing|
+
+    anyMissing := false.
+
+    Stdout showCR:'Creating suite...'.
+    suite := TestSuite named:'SelfTest'.
+
+    Stdout showCR:'Loading regression tests...'.
+    self listOfTestClasses do:[:className |
+        |fullName|
+
+        fullName := ('RegressionTests::',className).
+        Stdout showCR:('Loading ',className,'...').
+        Smalltalk fileInClass:fullName package:'exept:regression'.
+        (Smalltalk classNamed:fullName) isNil ifTrue:[
+            Stdout showCR:('**** Ouch - missing class: "',fullName,'"').
+            anyMissing := true.
+        ] ifFalse:[
+            suite addTest:(Smalltalk classNamed:fullName) suite.
+        ]
+    ].
+
+    anyError := anyError | anyMissing.
+!
+
+generateReport
+    Stdout showCR:'Generating report...'.
+    TestResultReporter
+        report:result
+        format:#xml_jUnit
+        as:'testresult.xml'.
+
+    Stdout showCR:'Summary:'.
+    Stdout showCR:('  %1 tests;' bindWith:result runCount).
+    Stdout show:('  %1 passed,' bindWith:result passedCount).
+    Stdout show:(' %1 failed,' bindWith:result failureCount).
+    Stdout showCR:(' %1 errors.' bindWith:result errorCount).
+!
+
+listOfTestClasses
+    ^ #(
+
+        "/ 'SunitXMLOutputTest'
+        'CoverageInstrumentationTest'
+        'AssociationTests'
+        'BinaryIOTests'
+        'BinaryTreeTester'
+        "/ 'BlockTest'
+        'CharacterTests'
+        'CollectionTests'
+        'CompilerTest'
+        'ComplexTest'
+        'STCCompilerTests'
+        "/ 'DebuggerTest'
+        "/ 'DeepCopyTests'
+        'DelayTest'
+        'DictionaryTest'
+        'EnumerationTests'
+        'ExceptionTest'
+        "/ 'ExternalInterfaceTests'
+        "/ 'FileOpenTest'
+        'FileStreamTest'
+        'FloatTest'
+        'FractionTest'
+        "/ 'GCTest'
+        "/ 'GraphicDrawingTest'
+        "/ 'HTMLParserTests'
+        "/ 'ImageReaderTest'
+        'IntegerTest'
+        'JavaScriptTests'
+        "/ 'MeasurementValueTests'
+        "/ 'MemoryTest'
+        'NumberTest'
+        "/ 'ParserTest'
+        'ScaledDecimalTest'
+        "/ 'SemaphoreTest'
+        "/ 'SharedQueueTest'
+        'SmallIntegerTest'
+        "/ 'SortTests'
+        'StringTests'
+        'StreamTests'
+        'TimeAndDateTest'
+        'TimeDurationTest'
+        "/ 'URLTest'
+        "/ 'XMLCoderTests'
+        "/ 'ZipArchiveTests'
+    )
+!
+
+prepare
+    "/ tell the system, where stx is...
+
+    |top|
+
+    top := Smalltalk packageDirectoryForPackageId:'stx'.
+    "/ top := '../../..'.
+
+    ParserFlags initializeSTCFlagsForTopDirectory:top.
+
+    Object infoPrinting:false.
+    ObjectMemory infoPrinting:false.
+
+    Processor activeProcess exceptionHandlerSet
+        on:(Class updateChangeFileQuerySignal)
+        do:[:ex | ex proceedWith:false ].
+
+    Stdout showCR:'Selftest Started'.
+
+    Stdout showCR:'Loading sunit...'.
+    Smalltalk loadPackage:'stx:goodies/sunit'.
+    self assert:(TestCase notNil and:[TestCase isLoaded]).
+
+    Smalltalk loadPackage:'stx:libcompat'.
+    Smalltalk loadPackage:'stx:libjavascript'.
+!
+
+runSuite
+    Stdout showCR:'Running suite...'.
+    result := suite
+                run:TestResultStX new beforeEachDo:[:test |
+                    Stdout showCR:('- running ',test printString).
+                ]
+                afterEachDo:[:test| ]
+                debug:(Smalltalk commandLineArgumentNamed:'--debug') notNil.
+! !
+
+!QuickTestRunner methodsFor:'initialization'!
+
+initialize
+    anyError := false.
+! !
+
+!QuickTestRunner class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
+! !