quickSelfTest/SelfTest.st
author Claus Gittinger <cg@exept.de>
Thu, 03 Mar 2016 18:25:02 +0100
changeset 297 a850936897fd
parent 130 ae4a40e279d6
child 298 a170cf03d2b0
permissions -rw-r--r--
*** empty log message ***

"/
"/ runs a number of tests from the exept:regression package (see list below)
"/ execute this script using the following command line:
"/
"/ stx --noBanner -I --execute SelfTest.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 SelfTest.st
"/
"/ and configure the jenkins junit plugin, to scan for "testresult.xml"

"/ tell the system, where stx is...
ParserFlags initializeSTCFlagsForTopDirectory:'../../..'.

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]) message:'[Error]: Missing TestCase class after sunit package load'.

"/ Smalltalk loadPackage:'stx:goodies/xml/vw'.
"/ Smalltalk loadPackage:'stx:goodies/xml/stx'.
Smalltalk loadPackage:'stx:libcompat'.
Smalltalk loadPackage:'stx:libjavascript'.
!

|suite result|

Stdout showCR:'Creating suite...'.
suite := TestSuite named:'SelfTest'.

Stdout showCR:'Loading regression tests...'.

"To add a new test please edit exept_regression>>testCaseNamesWithoutNamespace"
Smalltalk fileInClass:#'exept_regression' package:'exept:regression'.
(Smalltalk at: #'exept_regression') isNil ifTrue:[
    Stdout showCR:('ERROR: Ouch - missing class: "exept_regression"').
    Smalltalk exit: 1.
].
(Smalltalk at: #'exept_regression') testCaseNamesWithoutNamespace 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,'"').
    ] ifFalse:[
	suite addTest:(Smalltalk classNamed:fullName) suite.
    ]
].

Stdout showCR:'Running suite...'.
result := suite
	    run:TestResultStX new beforeEachDo:[:test |
		Stdout showCR:('- running ',test printString).
	    ]
	    afterEachDo:[:test| ]
	    debug:(Smalltalk commandLineArgumentNamed:'--debug') notNil.

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).

'metrics.xml' asFilename writingFileDo:[:stream |
    MetricsReporter new
	stream: stream;
	packages:{
	    'stx:libbasic'       .
	    'stx:libbasic2'      .
	    'stx:libbasic3'      .
	    'stx:libcomp'        .
	    'stx:libview'        .
	    'stx:libview2'       .
	    'stx:libwidg'        .
	    'stx:libwidg2'       .
	    'stx:libtool'        .
	    'stx:libtool2'       .
	    'stx:libui'          .
	    'stx:libhtml'        .
	    'stx:goodies/xml/vw' .
	    'stx:goodies/soap'   .
	    'stx:libjavascript'  .
	};
	classMetricNames: #();
	methodMetricNames: #();
	packageMetricNames: #( 'LOC' 'NOM' 'NOC');
	reportXml_metrics.
].

!