reports/Builder__ReportRunner.st
changeset 188 6eeac31d0432
parent 184 5f75ffc9642b
child 189 bd2bed33aba7
equal deleted inserted replaced
187:ee2471c56070 188:6eeac31d0432
    13 
    13 
    14 "
    14 "
    15  The following class instance variables are inherited by this class:
    15  The following class instance variables are inherited by this class:
    16 
    16 
    17 	StandaloneStartup - MutexHandle
    17 	StandaloneStartup - MutexHandle
    18 	Object - 
    18 	Object -
    19 "
    19 "
    20 !
    20 !
    21 
    21 
    22 
    22 
    23 !ReportRunner class methodsFor:'initialization'!
    23 !ReportRunner class methodsFor:'initialization'!
    38 
    38 
    39     ^CmdLineOption new
    39     ^CmdLineOption new
    40         short: $D;
    40         short: $D;
    41         long: 'output-directory';
    41         long: 'output-directory';
    42         description: 'Default report output directory';
    42         description: 'Default report output directory';
    43         action:[:outputdir | 
    43         action:[:outputdir |
    44             Report outputDir: outputdir.
    44             Report outputDir: outputdir.
    45             self  verboseInfo:'Report dir: ' , Report outputDir asString.
    45             self  verboseInfo:'Report dir: ' , Report outputDir asString.
    46         ]
    46         ]
    47 
    47 
    48     "Created: / 06-11-2011 / 09:33:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    48     "Created: / 06-11-2011 / 09:33:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    55         long: 'report';
    55         long: 'report';
    56         description: 'Report to run';
    56         description: 'Report to run';
    57         action:[:option |
    57         action:[:option |
    58             report := Smalltalk at: option asSymbol.
    58             report := Smalltalk at: option asSymbol.
    59             report isNil ifTrue:[
    59             report isNil ifTrue:[
    60                 Stderr nextPutLine:('ERROR: Report class %1 does not exist (forgot to load package?)' bindWith: option).        
    60                 Stderr nextPutLine:('ERROR: Report class %1 does not exist (forgot to load package?)' bindWith: option).
    61                 "/Smalltalk exit: 1.        
    61                 "/Smalltalk exit: 1.
    62             ].
    62             ].
    63             report := report new.
    63             report := report new.
    64             parser options addAll: (CmdLineOption optionsFor: report)
    64             parser options addAll: (CmdLineOption optionsFor: report)
    65         ]
    65         ]
    66 
    66 
    72 
    72 
    73     ^CmdLineOption new
    73     ^CmdLineOption new
    74         short: $s;
    74         short: $s;
    75         long: 'setup';
    75         long: 'setup';
    76         description: 'Code executed before tests are loaded and executed';
    76         description: 'Code executed before tests are loaded and executed';
    77         action:[:option | 
    77         action:[:option |
    78             setup := option
    78             setup := option
    79         ]
    79         ]
    80 
    80 
    81     "Created: / 15-05-2013 / 16:50:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    81     "Created: / 15-05-2013 / 16:50:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    82 !
    82 !
    85 
    85 
    86     ^CmdLineOption new
    86     ^CmdLineOption new
    87         short: $t;
    87         short: $t;
    88         long: 'setup';
    88         long: 'setup';
    89         description: 'Code executed after all tests are executed';
    89         description: 'Code executed after all tests are executed';
    90         action:[:option | 
    90         action:[:option |
    91             teardown := option
    91             teardown := option
    92         ]
    92         ]
    93 
    93 
    94     "Created: / 15-05-2013 / 16:50:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    94     "Created: / 15-05-2013 / 16:50:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    95 ! !
    95 ! !
   106     | ctx |
   106     | ctx |
   107     aStream cr; cr.
   107     aStream cr; cr.
   108     aStream nextPutAll: '== ['; nextPutAll: aProcess id printString; nextPutAll:'] '; nextPutAll: aProcess name; nextPutAll: ' =='; cr.
   108     aStream nextPutAll: '== ['; nextPutAll: aProcess id printString; nextPutAll:'] '; nextPutAll: aProcess name; nextPutAll: ' =='; cr.
   109     aStream cr.
   109     aStream cr.
   110 
   110 
   111     ctx := aProcess == Processor activeProcess ifTrue:[thisContext] ifFalse:[aProcess suspendedContext].
   111     aProcess == Processor activeProcess ifTrue:[ctx := thisContext] ifFalse:[ctx := aProcess suspendedContext].
   112     [ ctx notNil ] whileTrue:[
   112     [ ctx notNil ] whileTrue:[
   113         aStream nextPutAll: '  '.
   113         aStream nextPutAll: '  '.
   114         ctx fullPrintOn: aStream.   
   114         ctx fullPrintOn: aStream.
   115         aStream cr.
   115         aStream cr.
   116         ctx := ctx sender.
   116         ctx := ctx sender.
   117     ].
   117     ].
   118     aStream cr.
   118     aStream cr.
   119 
   119 
   207 
   207 
   208 setupSignalHandlers
   208 setupSignalHandlers
   209     "On UNIX, this sets up a custom signal handler on SIGUSR2 and SIGTERM that
   209     "On UNIX, this sets up a custom signal handler on SIGUSR2 and SIGTERM that
   210      dumps stacks on all threads"
   210      dumps stacks on all threads"
   211 
   211 
       
   212     | sigusr2 sigterm |
       
   213 
   212     OperatingSystem isUNIXlike ifTrue:[
   214     OperatingSystem isUNIXlike ifTrue:[
   213         | sigusr2 sigterm |
   215 
   214 
   216 
   215         sigterm := Signal new.
   217         sigterm := Signal new.
   216         sigterm handlerBlock: [:ex | self handleSIGTERM].
   218         sigterm handlerBlock: [:ex | self handleSIGTERM].
   217         OperatingSystem operatingSystemSignal:OperatingSystem sigTERM install: sigterm.
   219         OperatingSystem operatingSystemSignal:OperatingSystem sigTERM install: sigterm.
   218         OperatingSystem enableSignal: OperatingSystem sigTERM.
   220         OperatingSystem enableSignal: OperatingSystem sigTERM.
   222         OperatingSystem operatingSystemSignal:OperatingSystem sigUSR2 install: sigusr2.
   224         OperatingSystem operatingSystemSignal:OperatingSystem sigUSR2 install: sigusr2.
   223         OperatingSystem enableSignal: OperatingSystem sigUSR2.
   225         OperatingSystem enableSignal: OperatingSystem sigUSR2.
   224     ].
   226     ].
   225 
   227 
   226     "
   228     "
   227     OperatingSystem sendSignal: OperatingSystem sigUSR2 to: OperatingSystem getProcessId  
   229     OperatingSystem sendSignal: OperatingSystem sigUSR2 to: OperatingSystem getProcessId
   228     "
   230     "
   229 
   231 
   230     "Created: / 27-06-2013 / 20:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   232     "Created: / 27-06-2013 / 20:57:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   231     "Modified: / 28-06-2013 / 01:11:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   233     "Modified: / 28-06-2013 / 01:11:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   232 !
   234 !
   281     "Process command line arguments"
   283     "Process command line arguments"
   282 
   284 
   283     parser := CmdLineParser new.
   285     parser := CmdLineParser new.
   284     CmdLineOptionError autoload.
   286     CmdLineOptionError autoload.
   285 
   287 
   286     [               
   288     [
   287         parser parse: argv for: self.        
   289         parser parse: argv for: self.
   288     ] on:CmdLineOptionError do:[:ex|
   290     ] on:CmdLineOptionError do:[:ex|
   289         Stderr nextPutLine:'Error when processing options: ', ex description.
   291         Stderr nextPutLine:'Error when processing options: ', ex description.
   290         debugging ifFalse:[     
   292         debugging ifFalse:[
   291             ex suspendedContext fullPrintAllOn: Stderr.
   293             ex suspendedContext fullPrintAllOn: Stderr.
   292             Stderr nextPutLine:'Exiting'.
   294             Stderr nextPutLine:'Exiting'.
   293             Smalltalk exit:1.
   295             Smalltalk exit:1.
   294         ] ifTrue:[
   296         ] ifTrue:[
   295             ex pass
   297             ex pass
   296         ]        
   298         ]
   297     ].
   299     ].
   298 
   300 
   299     [
   301     [
   300         setup notNil ifTrue:[Compiler evaluate: setup].
   302         setup notNil ifTrue:[Compiler evaluate: setup].
   301         [
   303         [