Changeset 18730
- Timestamp:
- 05/28/09 14:42:24 (4 years ago)
- Files:
-
- tools/lime/trunk/lib/lime.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/lime/trunk/lib/lime.php
r18662 r18730 415 415 class lime_output 416 416 { 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_output458 {459 417 public $colorizer = null; 460 418 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); 464 422 } 465 423 … … 509 467 } 510 468 469 class lime_output_color extends lime_output 470 { 471 } 472 511 473 class lime_colorizer 512 474 { 513 475 static public $styles = array(); 514 476 477 protected $force_colors = false; 478 479 public function __construct($force_colors = false) 480 { 481 $this->force_colors = $force_colors; 482 } 483 515 484 public static function style($name, $options = array()) 516 485 { … … 518 487 } 519 488 520 public staticfunction colorize($text = '', $parameters = array())489 public function colorize($text = '', $parameters = array()) 521 490 { 522 491 // 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))) 524 493 { 525 494 return $text; … … 655 624 if ($delta > 0) 656 625 { 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->co lorizer->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'])))); 658 627 $this->stats[$file]['status'] = 'dubious'; 659 628 $this->stats[$file]['status_code'] = 255; … … 666 635 else if ($delta < 0) 667 636 { 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->co lorizer->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'])))); 669 638 $this->stats[$file]['status'] = 'dubious'; 670 639 $this->stats[$file]['status_code'] = 255;