author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 15 May 2013 18:00:14 +0200 | |
changeset 147 | 9f2935d68582 |
parent 144 | b38e5af6b408 |
child 184 | 5f75ffc9642b |
permissions | -rw-r--r-- |
72 | 1 |
"{ Package: 'stx:goodies/builder/reports' }" |
2 |
||
3 |
"{ NameSpace: Builder }" |
|
4 |
||
5 |
StandaloneStartup subclass:#ReportRunner |
|
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'Builder-Reports' |
|
10 |
! |
|
11 |
||
147
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
12 |
ReportRunner class instanceVariableNames:'parser report debugging setup teardown' |
72 | 13 |
|
14 |
" |
|
15 |
The following class instance variables are inherited by this class: |
|
16 |
||
17 |
StandaloneStartup - MutexHandle |
|
18 |
Object - |
|
19 |
" |
|
20 |
! |
|
21 |
||
22 |
||
23 |
!ReportRunner class methodsFor:'initialization'! |
|
24 |
||
25 |
initialize |
|
26 |
||
27 |
super initialize. |
|
28 |
debugging := Transcript notNil and:[Transcript isView]. |
|
29 |
||
30 |
"Created: / 06-11-2011 / 22:07:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
31 |
! ! |
|
32 |
||
33 |
!ReportRunner class methodsFor:'command line options'! |
|
34 |
||
35 |
cmdlineOptionOutputDirectory |
|
36 |
||
37 |
^CmdLineOption new |
|
38 |
short: $D; |
|
39 |
long: 'output-directory'; |
|
40 |
description: 'Default report output directory'; |
|
41 |
action:[:outputdir | |
|
42 |
Report outputDir: outputdir. |
|
43 |
self verboseInfo:'Report dir: ' , Report outputDir asString. |
|
44 |
] |
|
45 |
||
46 |
"Created: / 06-11-2011 / 09:33:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
47 |
! |
|
48 |
||
49 |
cmdlineOptionReport |
|
50 |
||
51 |
^CmdLineOption new |
|
52 |
short: $r; |
|
97
c6a5d1c4df41
changed: #cmdlineOptionReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
92
diff
changeset
|
53 |
long: 'report'; |
72 | 54 |
description: 'Report to run'; |
55 |
action:[:option | |
|
56 |
report := Smalltalk at: option asSymbol. |
|
57 |
report isNil ifTrue:[ |
|
78
d3f87f298062
Fix in default report file name for LintReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
77
diff
changeset
|
58 |
Stderr nextPutLine:('ERROR: Report class %1 does not exist (forgot to load package?)' bindWith: option). |
72 | 59 |
"/Smalltalk exit: 1. |
60 |
]. |
|
61 |
report := report new. |
|
62 |
parser options addAll: (CmdLineOption optionsFor: report) |
|
63 |
] |
|
64 |
||
65 |
"Created: / 06-11-2011 / 09:45:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
97
c6a5d1c4df41
changed: #cmdlineOptionReport
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
92
diff
changeset
|
66 |
"Modified: / 31-10-2012 / 12:40:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
147
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
67 |
! |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
68 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
69 |
cmdlineOptionSetup |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
70 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
71 |
^CmdLineOption new |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
72 |
short: $s; |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
73 |
long: 'setup'; |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
74 |
description: 'Code executed before tests are loaded and executed'; |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
75 |
action:[:option | |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
76 |
setup := option |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
77 |
] |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
78 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
79 |
"Created: / 15-05-2013 / 16:50:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
80 |
! |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
81 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
82 |
cmdlineOptionTeardown |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
83 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
84 |
^CmdLineOption new |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
85 |
short: $t; |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
86 |
long: 'setup'; |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
87 |
description: 'Code executed after all tests are executed'; |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
88 |
action:[:option | |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
89 |
teardown := option |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
90 |
] |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
91 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
92 |
"Created: / 15-05-2013 / 16:50:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
72 | 93 |
! ! |
94 |
||
95 |
!ReportRunner class methodsFor:'defaults'! |
|
96 |
||
77 | 97 |
allowCoverageMeasurementOption |
98 |
||
99 |
^false "CoverageReport will do that" |
|
100 |
||
101 |
"Created: / 13-01-2012 / 11:48:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
102 |
! |
|
103 |
||
72 | 104 |
allowDebugOption |
105 |
||
106 |
^true |
|
107 |
||
108 |
"Created: / 21-07-2011 / 09:48:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
109 |
! ! |
|
110 |
||
111 |
!ReportRunner class methodsFor:'multiple applications support'! |
|
112 |
||
113 |
applicationRegistryPath |
|
114 |
"the key under which this application stores its process ID in the registry |
|
115 |
as a collection of path-components. |
|
116 |
i.e. if #('foo' 'bar' 'baz') is returned here, the current applications ID will be stored |
|
117 |
in HKEY_CURRENT_USER\Software\foo\bar\baz\CurrentID. |
|
118 |
(would also be used as a relative path for a temporary lock file under unix). |
|
119 |
Used to detect if another instance of this application is already running." |
|
120 |
||
121 |
^ #('exept' 'smalltallx' 'hdreportrunner') |
|
122 |
||
123 |
"Modified: / 21-07-2011 / 09:43:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
124 |
! |
|
125 |
||
126 |
applicationUUID |
|
127 |
"answer an application-specific unique uuid. |
|
128 |
This is used as the name of some exclusive OS-resource, which is used to find out, |
|
129 |
if another instance of this application is already running. |
|
130 |
Under win32, a mutex is used; under unix, an exclusive file in the tempDir could be used." |
|
131 |
||
132 |
^ '99f65c80-b375-11e0-86ad-0013e89c0459' asUUID |
|
133 |
||
134 |
"Modified: / 21-07-2011 / 09:44:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
135 |
! ! |
|
136 |
||
137 |
!ReportRunner class methodsFor:'startup'! |
|
138 |
||
139 |
setupToolsForDebug |
|
140 |
||
141 |
super setupToolsForDebug. |
|
142 |
debugging := true. |
|
143 |
||
144 |
"Created: / 06-11-2011 / 22:06:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
77 | 145 |
! |
146 |
||
147 |
usage |
|
148 |
||
149 |
Stderr nextPutAll:'usage: report-runner.'; |
|
150 |
nextPutAll: (OperatingSystem isMSWINDOWSlike ifTrue:['bat'] ifFalse:['sh']); |
|
151 |
nextPutAll: ' [-D <dir>] -r <report> [-p <package1> [-p <package2> [...]]]'; cr. |
|
152 |
||
153 |
Stderr nextPutLine:' --help .................. output this message'. |
|
154 |
Stderr nextPutLine:' --verbose ............... verbose startup'. |
|
155 |
Stderr nextPutLine:' --noBanner .............. no splash screen'. |
|
156 |
Stderr nextPutLine:' --newAppInstance ........ start as its own application process (do not reuse a running instance)'. |
|
157 |
self allowScriptingOption ifTrue:[ |
|
158 |
Stderr nextPutLine:' --scripting portNr ...... enable scripting via port (or stdin/stdOut, if 0)'. |
|
159 |
]. |
|
160 |
self allowDebugOption ifTrue:[ |
|
161 |
Stderr nextPutLine:' --debug ................. enable Debugger'. |
|
162 |
]. |
|
163 |
||
164 |
"/ ' ......................... ' |
|
165 |
Stderr nextPutLine:' -D <dir>'. |
|
166 |
Stderr nextPutLine:' --output-directory=<dir> directory where report files will go'. |
|
167 |
Stderr nextPutLine:' -r <report class>'. |
|
168 |
Stderr nextPutLine:' --report=<report class> . report to run. available reports:'. |
|
169 |
Report available do:[:report| |
|
170 |
Stderr nextPutAll:' '; nextPutLine: report name |
|
171 |
]. |
|
172 |
Stderr nextPutLine:' -p <package>'. |
|
173 |
Stderr nextPutLine:' --package=<package> ..... package to run report on'. |
|
174 |
Stderr nextPutLine:' May be specified multiple times.'. |
|
175 |
||
176 |
" |
|
177 |
self usage |
|
178 |
" |
|
179 |
||
180 |
"Created: / 13-01-2012 / 11:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
72 | 181 |
! ! |
182 |
||
183 |
!ReportRunner class methodsFor:'startup-to be redefined'! |
|
184 |
||
102
a63aa44303e3
changed: #main: - support for not-officially-supported VM options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
97
diff
changeset
|
185 |
main:argv |
143 | 186 |
"Process command line arguments" |
102
a63aa44303e3
changed: #main: - support for not-officially-supported VM options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
97
diff
changeset
|
187 |
|
72 | 188 |
parser := CmdLineParser new. |
144 | 189 |
CmdLineOptionError autoload. |
190 |
||
72 | 191 |
[ |
143 | 192 |
parser parse: argv for: self. |
193 |
] on:CmdLineOptionError do:[:ex| |
|
72 | 194 |
Stderr nextPutLine:'Error when processing options: ', ex description. |
92 | 195 |
debugging ifFalse:[ |
196 |
ex suspendedContext fullPrintAllOn: Stderr. |
|
72 | 197 |
Stderr nextPutLine:'Exiting'. |
198 |
Smalltalk exit:1. |
|
199 |
] ifTrue:[ |
|
200 |
ex pass |
|
201 |
] |
|
202 |
]. |
|
203 |
||
204 |
[ |
|
147
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
205 |
setup notNil ifTrue:[Compiler evaluate: setup]. |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
206 |
[ |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
207 |
report run. |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
208 |
] ensure:[ |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
209 |
teardown notNil ifTrue:[Compiler evaluate: teardown]. |
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
210 |
]. |
72 | 211 |
debugging ifFalse:[ |
212 |
Smalltalk exit:0. |
|
213 |
]. |
|
214 |
] on: Error do:[:ex| |
|
215 |
Stderr nextPutAll:'Error when running tests: '. |
|
216 |
Stderr nextPutAll:ex description; cr. |
|
217 |
ex suspendedContext printAllOn:Stderr. |
|
147
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
218 |
|
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
219 |
|
72 | 220 |
debugging ifFalse:[ |
221 |
Smalltalk exit:1. |
|
222 |
] ifTrue:[ |
|
223 |
ex pass |
|
224 |
] |
|
225 |
] |
|
226 |
||
147
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
227 |
"Modified: / 15-05-2013 / 16:52:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
72 | 228 |
! ! |
229 |
||
230 |
!ReportRunner class methodsFor:'documentation'! |
|
231 |
||
232 |
version |
|
233 |
^ '$Header$' |
|
234 |
! |
|
235 |
||
236 |
version_CVS |
|
237 |
^ '$Header$' |
|
238 |
! |
|
239 |
||
240 |
version_SVN |
|
147
9f2935d68582
class: Builder::ReportRunner
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
144
diff
changeset
|
241 |
^ '$Id$' |
72 | 242 |
! ! |
243 |
||
143 | 244 |
|
72 | 245 |
ReportRunner initialize! |