Development

Changeset 21244

You must first sign up to be able to contribute.

Changeset 21244

Show
Ignore:
Timestamp:
08/18/09 23:14:30 (5 years ago)
Author:
bschussek
Message:

Added --verbose switch to LimeOutputConsoleSummary?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleSummary.php

    r21239 r21244  
    2222    $failedTests    = 0, 
    2323    $expected       = array(), 
     24    $actual         = array(), 
    2425    $passed         = array(), 
    2526    $failed         = array(), 
     
    3536      'base_dir'  => null, 
    3637      'processes' => 1, 
     38      'verbose'   => false, 
    3739    ), $options); 
    3840  } 
     
    5153      $this->line[$file] = count($this->line); 
    5254      $this->expected[$file] = 0; 
     55      $this->actual[$file] = 0; 
    5356      $this->passed[$file] = 0; 
    54       $this->failed[$file] = 0
    55       $this->errors[$file] = 0
    56       $this->warnings[$file] = 0
     57      $this->failed[$file] = array()
     58      $this->errors[$file] = array()
     59      $this->warnings[$file] = array()
    5760    } 
    5861  } 
     
    6669      $this->failedTests += $this->getFailed(); 
    6770 
    68       $path = $this->getTruncatedFile(); 
     71      $path = $this->truncate($this->file); 
    6972 
    7073      if (strlen($path) > 71) 
     
    103106      } 
    104107 
     108 
    105109      if ($this->getErrors() || $this->getWarnings() || $this->getFailed() || $incomplete) 
    106110      { 
     
    114118        } 
    115119      } 
     120 
     121      if ($this->options['verbose']) 
     122      { 
     123        if ($this->getFailed()) 
     124        { 
     125          $this->printer->printLine('  Failed Tests:', LimePrinter::COMMENT); 
     126 
     127          foreach ($this->failed[$this->file] as $number => $failed) 
     128          { 
     129            $this->printer->printLine('    not ok '.$number.' - '.$failed[0]); 
     130            $this->printer->printText('      (in '); 
     131            $this->printer->printText($this->truncate($failed[1]), LimePrinter::TRACE); 
     132            $this->printer->printText(' on line '); 
     133            $this->printer->printText($failed[2], LimePrinter::TRACE); 
     134            $this->printer->printLine(')'); 
     135          } 
     136        } 
     137 
     138        if ($this->getWarnings()) 
     139        { 
     140          $this->printer->printLine('  Warnings:', LimePrinter::COMMENT); 
     141 
     142          foreach ($this->warnings[$this->file] as $warning) 
     143          { 
     144            $this->printer->printLine('    '.$warning[0]); 
     145            $this->printer->printText('      (in '); 
     146            $this->printer->printText($this->truncate($warning[1]), LimePrinter::TRACE); 
     147            $this->printer->printText(' on line '); 
     148            $this->printer->printText($warning[2], LimePrinter::TRACE); 
     149            $this->printer->printLine(')'); 
     150          } 
     151        } 
     152 
     153        if ($this->getErrors()) 
     154        { 
     155          $this->printer->printLine('  Errors:', LimePrinter::COMMENT); 
     156 
     157          foreach ($this->errors[$this->file] as $error) 
     158          { 
     159            $this->printer->printLine('    '.$error->getMessage()); 
     160            $this->printer->printText('      (in '); 
     161            $this->printer->printText($this->truncate($error->getFile()), LimePrinter::TRACE); 
     162            $this->printer->printText(' on line '); 
     163            $this->printer->printText($error->getLine(), LimePrinter::TRACE); 
     164            $this->printer->printLine(')'); 
     165          } 
     166        } 
     167      } 
    116168    } 
    117169  } 
     
    124176  protected function getActual() 
    125177  { 
    126     return $this->getPassed() + $this->getFailed()
     178    return $this->actual[$this->file]
    127179  } 
    128180 
     
    134186  protected function getFailed() 
    135187  { 
    136     return $this->failed[$this->file]
     188    return count($this->failed[$this->file])
    137189  } 
    138190 
    139191  protected function getErrors() 
    140192  { 
    141     return $this->errors[$this->file]
     193    return count($this->errors[$this->file])
    142194  } 
    143195 
    144196  protected function getWarnings() 
    145197  { 
    146     return $this->warnings[$this->file]; 
    147   } 
    148  
    149   protected function setCursor() 
    150   { 
    151     for ($i = count($this->line); $i > $this->line[$this->file]; --$i) 
    152     { 
    153       $this->printer->previousLine(); 
    154     } 
    155   } 
    156  
    157   protected function resetCursor() 
    158   { 
    159     for ($i = $this->line[$this->file]; $i < count($this->line); ++$i) 
    160     { 
    161       $this->printer->nextLine(); 
    162     } 
     198    return count($this->warnings[$this->file]); 
    163199  } 
    164200 
     
    171207  { 
    172208    $this->passed[$this->file]++; 
     209    $this->actual[$this->file]++; 
    173210  } 
    174211 
    175212  public function fail($message, $file, $line, $error = null) 
    176213  { 
    177     $this->failed[$this->file]++; 
     214    $this->actual[$this->file]++; 
     215    $this->failed[$this->file][$this->actual[$this->file]] = array($message, $file, $line); 
    178216  } 
    179217 
    180218  public function skip($message, $file, $line) {} 
    181219 
    182   public function todo($message, $file, $line) 
    183   { 
    184   } 
     220  public function todo($message, $file, $line) {} 
    185221 
    186222  public function warning($message, $file, $line) 
    187223  { 
    188     $this->warnings[$this->file]++
     224    $this->warnings[$this->file][] = array($message, $file, $line)
    189225  } 
    190226 
    191227  public function error(Exception $exception) 
    192228  { 
    193     $this->errors[$this->file]++
     229    $this->errors[$this->file][] = $exception
    194230  } 
    195231 
     
    217253  } 
    218254 
    219   protected function getTruncatedFile(
    220   { 
    221     if (!is_null($this->options)) 
    222     { 
    223       return str_replace($this->options['base_dir'], '', $this->file); 
     255  protected function truncate($file
     256  { 
     257    if (!is_null($this->options['base_dir'])) 
     258    { 
     259      return str_replace($this->options['base_dir'], '', $file); 
    224260    } 
    225261    else 
    226262    { 
    227       return $this->file; 
     263      return $file; 
    228264    } 
    229265  } 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleSummaryTest.php

    r21239 r21244  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(39); 
     16$t = new LimeTest(76); 
    1717 
    1818 
     
    137137 
    138138 
     139// @Test: When close() is called and the option "verbose" is set, all failure and error messages are listed 
     140 
     141  // fixtures 
     142  $printer->any('printText'); 
     143  $printer->any('printLine'); 
     144  $printer->any('printText'); 
     145  $printer->any('printLine')->times(3); 
     146  $printer->printLine('  Failed Tests:', LimePrinter::COMMENT); 
     147  $printer->printLine('    not ok 2 - A failed test'); 
     148  $printer->printText('      (in '); 
     149  $printer->printText('/test/script', LimePrinter::TRACE); 
     150  $printer->printText(' on line '); 
     151  $printer->printText('11', LimePrinter::TRACE); 
     152  $printer->printLine(')'); 
     153  $printer->printLine('    not ok 3 - A failed test'); 
     154  $printer->printText('      (in '); 
     155  $printer->printText('/test/script', LimePrinter::TRACE); 
     156  $printer->printText(' on line '); 
     157  $printer->printText('11', LimePrinter::TRACE); 
     158  $printer->printLine(')'); 
     159  $printer->printLine('  Warnings:', LimePrinter::COMMENT); 
     160  $printer->printLine('    A warning'); 
     161  $printer->printText('      (in '); 
     162  $printer->printText('/test/script', LimePrinter::TRACE); 
     163  $printer->printText(' on line '); 
     164  $printer->printText('11', LimePrinter::TRACE); 
     165  $printer->printLine(')'); 
     166  $printer->printLine('  Errors:', LimePrinter::COMMENT); 
     167  $printer->printLine('    An error'); 
     168  $printer->printText('      (in '); 
     169  $printer->printText('/test/script', LimePrinter::TRACE); 
     170  $printer->printText(' on line '); 
     171  $printer->printText('11', LimePrinter::TRACE); 
     172  $printer->printLine(')'); 
     173  $printer->printLine('    An error'); 
     174  $printer->printText('      (in '); 
     175  $printer->printText('/test/script', LimePrinter::TRACE); 
     176  $printer->printText(' on line '); 
     177  $printer->printText('11', LimePrinter::TRACE); 
     178  $printer->printLine(')'); 
     179  $printer->replay(); 
     180  $output = new LimeOutputConsoleSummary($printer, array('verbose' => true)); 
     181  // test 
     182  $output->focus('/test/script'); 
     183  $output->pass('A passed test', '/test/script', 11); 
     184  $output->fail('A failed test', '/test/script', 11); 
     185  $output->fail('A failed test', '/test/script', 11); 
     186  $output->warning('A warning', '/test/script', 11); 
     187  $output->error(new LimeError('An error', '/test/script', 11)); 
     188  $output->error(new LimeError('An error', '/test/script', 11)); 
     189  $output->close(); 
     190  // assertions 
     191  $printer->verify(); 
     192 
     193 
    139194// @Test: flush() prints a summary of all files if failures occured 
    140195