1 "/ |
|
2 "/ runs a number of tests from the exept:regression package (see list below) |
|
3 "/ execute this script using the following command line: |
|
4 "/ |
|
5 "/ stx --noBanner -I --execute SelfTest.st |
|
6 "/ |
|
7 "/ use |
|
8 "/ --debug to debug failed test cases. |
|
9 "/ --skipTests to skip tests |
|
10 "/ --skipMetrics to metric reports tests |
|
11 "/ |
|
12 "/ To use with jenkins (+ jUnit plugin): |
|
13 "/ use the following buildscript (in jenkins): |
|
14 "/ (after checkout of stx) |
|
15 "/ cd stx |
|
16 "/ call bmake |
|
17 "/ cd goodies\selftest |
|
18 "/ ..\..\projects\smalltalk\stx.com --noBanner -I --execute SelfTest.st |
|
19 "/ |
|
20 "/ and configure the jenkins junit plugin, to scan for "testresult.xml" |
|
21 "/ ------------------------------------------------------------------------------------ |
|
22 |
|
23 "/ tell the system, where stx is... |
|
24 ParserFlags initializeSTCFlagsForTopDirectory:'../../..'. |
|
25 |
|
26 Object infoPrinting:false. |
|
27 ObjectMemory infoPrinting:false. |
|
28 |
|
29 "/ install a global handler, which suppresses the updating of the change file |
|
30 Processor activeProcess exceptionHandlerSet |
|
31 on:(Class updateChangeFileQuerySignal) |
|
32 do:[:ex | ex proceedWith:false ]. |
|
33 ! |
|
34 |
|
35 Stdout showCR:'Selftest Started'. |
|
36 ! |
|
37 |
|
38 Smalltalk packagePath addFirst:'../../../..'. |
|
39 |
|
40 "/ ensure that some packages are present |
|
41 Stdout showCR:'Loading sunit...'. |
|
42 Smalltalk loadPackage:'stx:goodies/sunit'. |
|
43 self assert:(TestCase notNil and:[TestCase isLoaded]) message:'[Error]: Missing TestCase class after sunit package load'. |
|
44 |
|
45 "/ Smalltalk loadPackage:'stx:goodies/xml/vw'. |
|
46 "/ Smalltalk loadPackage:'stx:goodies/xml/stx'. |
|
47 Smalltalk loadPackage:'stx:libcompat'. |
|
48 Smalltalk loadPackage:'stx:libjavascript'. |
|
49 ! |
|
50 |
|
51 |suite result debugging| |
|
52 |
|
53 Stdout showCR:'Creating suite...'. |
|
54 suite := TestSuite named:'SelfTest'. |
|
55 |
|
56 Stdout showCR:'Loading regression tests...'. |
|
57 |
|
58 "To add a new test please edit stx_goodies_regression>>testCaseNamesWithoutNamespace" |
|
59 Smalltalk fileInClass:#'stx_goodies_regression' package:'stx:goodies/regression'. |
|
60 (Smalltalk at: #'stx_goodies_regression') isNil ifTrue:[ |
|
61 Stdout showCR:('ERROR: Ouch - missing class: "stx_goodies_regression"'). |
|
62 Smalltalk exit: 1. |
|
63 ]. |
|
64 |
|
65 (Smalltalk at: #'stx_goodies_regression') testCaseNamesWithoutNamespace do:[:className | |
|
66 |fullName| |
|
67 |
|
68 fullName := ('RegressionTests::',className). |
|
69 Stdout showCR:(' loading ',className,'...'). |
|
70 Error handle:[:ex | |
|
71 Stdout showCR:('**** Ouch - error while loading class: "',className,'"'). |
|
72 ] do:[ |
|
73 Smalltalk fileInClass:fullName package:'stx:goodies/regression'. |
|
74 ]. |
|
75 (Smalltalk classNamed:fullName) isNil ifTrue:[ |
|
76 Stdout showCR:('**** Ouch - missing class: "',fullName,'"'). |
|
77 ] ifFalse:[ |
|
78 suite addTest:(Smalltalk classNamed:fullName) suite. |
|
79 ] |
|
80 ]. |
|
81 |
|
82 "/ |
|
83 "/ run the suite |
|
84 "/ |
|
85 (Smalltalk commandLineArguments includes:'--skipTests') ifTrue:[ |
|
86 Stdout showCR:'Skipping suite.'. |
|
87 ] ifFalse:[ |
|
88 Stdout showCR:'Running suite...'. |
|
89 debugging := (Smalltalk commandLineArguments includes:'--debug'). |
|
90 result := suite |
|
91 run:TestResultStX new |
|
92 beforeEachDo:[:test | |
|
93 Stdout showCR:('- running ',test printString). |
|
94 ] |
|
95 afterEachDo:[:test| |
|
96 Stdout showCR:('- done ',test printString). |
|
97 ] |
|
98 debug:debugging. |
|
99 |
|
100 Stdout showCR:'Generating report...'. |
|
101 TestResultReporter |
|
102 report:result |
|
103 format:#xml_jUnit |
|
104 as:'testresult.xml'. |
|
105 |
|
106 Stdout showCR:'Summary:'. |
|
107 Stdout showCR:(' %1 tests;' bindWith:result runCount). |
|
108 Stdout show:(' %1 passed,' bindWith:result passedCount). |
|
109 Stdout show:(' %1 failed,' bindWith:result failureCount). |
|
110 Stdout showCR:(' %1 errors.' bindWith:result errorCount). |
|
111 ]. |
|
112 |
|
113 "/ |
|
114 "/ generate a metrics report |
|
115 "/ |
|
116 #( |
|
117 'stx:libbasic' |
|
118 'stx:libbasic2' |
|
119 'stx:libbasic3' |
|
120 'stx:libcomp' |
|
121 'stx:libview' |
|
122 'stx:libview2' |
|
123 'stx:libwidg' |
|
124 'stx:libwidg2' |
|
125 'stx:libtool' |
|
126 'stx:libtool2' |
|
127 'stx:libui' |
|
128 'stx:libhtml' |
|
129 'stx:libboss' |
|
130 'stx:libdb' |
|
131 'stx:libjavascript' |
|
132 'stx:goodies/xml/stx' |
|
133 'stx:goodies/xml/yaxo' |
|
134 'stx:goodies/xml/xsl' |
|
135 'stx:goodies/xml/xpath' |
|
136 'stx:goodies/net' |
|
137 'stx:goodies/communication' |
|
138 'stx:goodies/webServer' |
|
139 'stx:goodies/soap' |
|
140 ) do:[:p | Smalltalk loadPackage:p]. |
|
141 |
|
142 (Smalltalk commandLineArguments includes:'--skipMetrics') ifTrue:[ |
|
143 Stdout showCR:'Skipping metrics.'. |
|
144 ] ifFalse:[ |
|
145 'metrics.xml' asFilename writingFileDo:[:stream | |
|
146 MetricsReporter new |
|
147 stream: stream; |
|
148 packages:{ |
|
149 'stx:*' . |
|
150 }; |
|
151 classMetricNames: #(); |
|
152 methodMetricNames: #(); |
|
153 packageMetricNames: #( 'LOC' 'NOM' 'NOC'); |
|
154 reportXml_metrics. |
|
155 ]. |
|
156 ]. |
|
157 |
|
158 ! |
|