Changeset 29

Show
Ignore:
Timestamp:
03/06/09 13:15:28 (3 years ago)
Author:
mgalloy
Message:

Using MG_ANSICODES when it is available.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/mgunit/src/mgutclirunner__define.pro

    r17 r29  
    33;+ 
    44; Results for tests, test cases, and test suites are reported to the test  
    5 ; runner. The MGtestCliRunner displays the results in the output log or in a  
     5; runner. The MGutCliRunner displays the results in the output log or in a  
    66; log file. 
    77;- 
     
    4747; :Keywords: 
    4848;    npass : in, required, type=integer  
    49 ;          number of passing tests contained in the hierarchy below the test  
    50 ;          suite 
     49;       number of passing tests contained in the hierarchy below the test  
     50;       suite 
    5151;    nfail : in, required, type=integer 
    5252;       number of failing tests contained in the hierarchy below the test  
     
    144144 
    145145  if (passed) then begin 
    146     printf, self.logLun, 'passed' 
     146    self->_print, self.logLun, 'passed', /green 
    147147  endif else begin 
    148     printf, self.logLun, 'failed' + (msg eq '' ? '' : ' "' + msg + '"') 
     148    self->_print, self.logLun, 'failed' + (msg eq '' ? '' : ' "' + msg + '"'), /red 
    149149  endelse 
     150end 
     151 
     152 
     153;+ 
     154; Prints a message to a LUN. 
     155; 
     156; :Params: 
     157;    lun : in, required, type=long 
     158;       logical unit number to print to 
     159;    text : in, required, type=string 
     160;       text to print 
     161; 
     162; :Keywords: 
     163;    _extra : in, optional, type=keywords 
     164;       keywords to MG_ANSICODE i.e. RED or GREEN 
     165;- 
     166pro mgutclirunner::_print, lun, text, _extra=e 
     167  compile_opt strictarr 
     168   
     169  if (self.isTty) then begin 
     170    printf, lun, mg_ansicode(text, _extra=e) 
     171  endif else begin 
     172    printf, lun, text 
     173  endelse 
     174end 
     175 
     176 
     177;+ 
     178; Safe method of determining if the current terminal is TTY. 
     179; 
     180; :Returns: 
     181;    1 if the terminal is TTY, 0 if not 
     182;- 
     183function mgutclirunner::_findIfTty 
     184  compile_opt strictarr 
     185   
     186  catch, error 
     187  if (error ne 0L) then begin 
     188    catch, /cancel 
     189    return, 0 
     190  endif 
     191   
     192  return, mg_termIsTty() 
    150193end 
    151194 
     
    193236  self.indent = 3L 
    194237  self.space = (byte(' '))[0] 
    195  
     238  self.isTty = self->_findIfTty() 
     239   
    196240  !quiet = 1 
    197241  return, 1B 
     
    216260             logLun : 0L, $ 
    217261             indent : 0L, $ 
    218              space : 0B $ 
     262             space : 0B, $ 
     263             isTty: 0B $ 
    219264           } 
    220265end