Development

Changeset 18730

You must first sign up to be able to contribute.

Changeset 18730

Show
Ignore:
Timestamp:
05/28/09 14:42:24 (4 years ago)
Author:
fabien
Message:

[lime] deprecated lime_output_color

The lime_output_color class is now deprecated. The class still exists for BC and just extends lime_output.

The lime_output constructor now takes an argument to force coloring output.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/trunk/lib/lime.php

    r18662 r18730  
    415415class lime_output 
    416416{ 
    417   public function diag() 
    418   { 
    419     $messages = func_get_args(); 
    420     foreach ($messages as $message) 
    421     { 
    422       array_map(array($this, 'comment'), (array) $message); 
    423     } 
    424   } 
    425  
    426   public function comment($message) 
    427   { 
    428     echo "# $message\n"; 
    429   } 
    430  
    431   public function info($message) 
    432   { 
    433     echo "> $message\n"; 
    434   } 
    435  
    436   public function error($message) 
    437   { 
    438     echo "> $message\n"; 
    439   } 
    440  
    441   public function echoln($message) 
    442   { 
    443     echo "$message\n"; 
    444   } 
    445  
    446   public function green_bar($message) 
    447   { 
    448     echo "$message\n"; 
    449   } 
    450  
    451   public function red_bar($message) 
    452   { 
    453     echo "$message\n"; 
    454   } 
    455 } 
    456  
    457 class lime_output_color extends lime_output 
    458 { 
    459417  public $colorizer = null; 
    460418 
    461   public function __construct(
    462   { 
    463     $this->colorizer = new lime_colorizer(); 
     419  public function __construct($force_colors = false
     420  { 
     421    $this->colorizer = new lime_colorizer($force_colors); 
    464422  } 
    465423 
     
    509467} 
    510468 
     469class lime_output_color extends lime_output 
     470{ 
     471} 
     472 
    511473class lime_colorizer 
    512474{ 
    513475  static public $styles = array(); 
    514476 
     477  protected $force_colors = false; 
     478 
     479  public function __construct($force_colors = false) 
     480  { 
     481    $this->force_colors = $force_colors; 
     482  } 
     483 
    515484  public static function style($name, $options = array()) 
    516485  { 
     
    518487  } 
    519488 
    520   public static function colorize($text = '', $parameters = array()) 
     489  public function colorize($text = '', $parameters = array()) 
    521490  { 
    522491    // disable colors if not supported (windows or non tty console) 
    523     if (DIRECTORY_SEPARATOR == '\\' || !function_exists('posix_isatty') || !@posix_isatty(STDOUT)) 
     492    if (!$this->force_colors && (DIRECTORY_SEPARATOR == '\\' || !function_exists('posix_isatty') || !@posix_isatty(STDOUT))) 
    524493    { 
    525494      return $text; 
     
    655624        if ($delta > 0) 
    656625        { 
    657           $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->output->colorizer->colorize(sprintf('# Looks like you planned %d tests but only ran %d.', $this->stats[$file]['plan'], $this->stats[$file]['nb_tests']), 'COMMENT'))); 
     626          $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->output->comment(sprintf('# Looks like you planned %d tests but only ran %d.', $this->stats[$file]['plan'], $this->stats[$file]['nb_tests'])))); 
    658627          $this->stats[$file]['status'] = 'dubious'; 
    659628          $this->stats[$file]['status_code'] = 255; 
     
    666635        else if ($delta < 0) 
    667636        { 
    668           $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->output->colorizer->colorize(sprintf('# Looks like you planned %s test but ran %s extra.', $this->stats[$file]['plan'], $this->stats[$file]['nb_tests'] - $this->stats[$file]['plan']), 'COMMENT'))); 
     637          $this->output->echoln(sprintf('%s%s%s', substr($relative_file, -min(67, strlen($relative_file))), str_repeat('.', 70 - min(67, strlen($relative_file))), $this->output->comment(sprintf('# Looks like you planned %s test but ran %s extra.', $this->stats[$file]['plan'], $this->stats[$file]['nb_tests'] - $this->stats[$file]['plan'])))); 
    669638          $this->stats[$file]['status'] = 'dubious'; 
    670639          $this->stats[$file]['status_code'] = 255;