Development

Changeset 21230

You must first sign up to be able to contribute.

Changeset 21230

Show
Ignore:
Timestamp:
08/18/09 21:44:37 (5 years ago)
Author:
bschussek
Message:

Added support for parallel processing in LimeTestSuite? by using the --processes switch

Files:

Legend:

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

    r20981 r21230  
    147147  } 
    148148 
    149   public function executeCallback($callback, $file, array $arguments = array()) 
     149  public function spawn($file, array $arguments = array()) 
    150150  { 
    151     $handle = popen($this->buildCommand($file, $arguments), 'r'); 
    152  
    153     while (!feof($handle)) 
    154     { 
    155       $line = fread($handle, 2048); 
    156       call_user_func($callback, $line); 
    157     } 
     151    return popen($this->buildCommand($file, $arguments), 'r'); 
    158152  } 
    159153 
  • tools/lime/branches/2.0-experimental/lib/LimeTest.php

    r20975 r21230  
    6060    } 
    6161 
    62     $this->output->start($file); 
     62    $this->output->focus($file); 
    6363 
    6464    if (!is_null($plan)) 
     
    7373  public function __destruct() 
    7474  { 
     75    $this->output->close(); 
    7576    $this->output->flush(); 
    7677 
  • tools/lime/branches/2.0-experimental/lib/LimeTestSuite.php

    r20968 r21230  
    1919  public function __construct(array $options = array()) 
    2020  { 
    21     $this->options = array
     21    $this->options = array_merge(array
    2222      'base_dir'     => null, 
    2323      'executable'   => null, 
     
    2626      'verbose'      => false, 
    2727      'serialize'    => false, 
    28     ); 
     28      'processes'    => 1, 
     29    ), $options); 
    2930 
    3031    foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) 
     
    3233      $this->options[str_replace('-', '_', $argument)] = $value; 
    3334    } 
    34  
    35     $this->options = array_merge($this->options, $options); 
    3635 
    3736    $this->options['base_dir'] = realpath($this->options['base_dir']); 
     
    4140      $factory = new LimeOutputFactory($this->options); 
    4241 
    43       $this->options['output'] = $factory->create($this->options['output']); 
     42      $type = $this->options['output']; 
     43      $output = $factory->create($type); 
     44    } 
     45    else 
     46    { 
     47      $output = $this->options['output']; 
     48      $type = get_class($output); 
    4449    } 
    4550 
    46     $this->output = new LimeOutputInspectable($this->options['output']); 
     51    if ($this->options['processes'] > 1 && !$output->supportsThreading()) 
     52    { 
     53      throw new LogicException(sprintf('The output "%s" does not support threading', $type)); 
     54    } 
     55 
     56    $this->output = new LimeOutputInspectable($output); 
    4757  } 
    4858 
     
    5666    // sort the files to be able to predict the order 
    5767    sort($this->files); 
     68    reset($this->files); 
    5869 
    59     $connector = new LimeOutputPipe($this->output, array('start', 'flush')); 
     70    $connectors = array(); 
    6071 
    61     foreach ($this->files as $file
     72    for ($i = 0; $i < $this->options['processes']; ++$i
    6273    { 
    63       // start the file explicitly in case the file contains syntax errors 
    64       $this->output->start($file); 
    65       $connector->connect($file); 
     74      $connectors[] = new LimeOutputPipe($this->output, array('focus', 'flush')); 
    6675    } 
     76 
     77    do 
     78    { 
     79      $done = true; 
     80 
     81      foreach ($connectors as $connector) 
     82      { 
     83        if ($connector->done() && !is_null(key($this->files))) 
     84        { 
     85          // start the file explicitly in case the file contains syntax errors 
     86          $this->output->focus(current($this->files)); 
     87          $connector->connect(current($this->files)); 
     88 
     89          next($this->files); 
     90        } 
     91        else if (!$connector->done()) 
     92        { 
     93          $this->output->focus($connector->getConnectedFile()); 
     94        } 
     95 
     96        if (!$connector->done()) 
     97        { 
     98          $connector->proceed(); 
     99          $done = false; 
     100        } 
     101      } 
     102    } 
     103    while (!$done); 
    67104 
    68105    $this->output->flush(); 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputArray.php

    r20975 r21230  
    2222  } 
    2323 
    24   public function start($file) 
     24  public function supportsThreading() 
     25  { 
     26    return true; 
     27  } 
     28 
     29  public function focus($file) 
    2530  { 
    2631    $this->currentResults =& $this->getResults($file); 
     32  } 
     33 
     34  public function close() 
     35  { 
    2736  } 
    2837 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleDetailed.php

    r20976 r21230  
    3030  } 
    3131 
     32  public function supportsThreading() 
     33  { 
     34    return false; 
     35  } 
     36 
    3237  private function stripBaseDir($path) 
    3338  { 
     
    3540  } 
    3641 
    37   public function start($file) 
     42  public function focus($file) 
    3843  { 
    3944    $this->printer->printLine('# '.$this->stripBaseDir($file), LimePrinter::INFO); 
     45  } 
     46 
     47  public function close() 
     48  { 
    4049  } 
    4150 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleSummary.php

    r20978 r21230  
    1313{ 
    1414  protected 
    15     $printer = null, 
    16     $options = array(), 
    17     $startTime = 0, 
    18     $file = null, 
    19     $actualFiles = 0, 
    20     $failedFiles = 0, 
    21     $actualTests = 0, 
    22     $failedTests = 0, 
    23     $expected = 0, 
    24     $passed = 0, 
    25     $failed = 0, 
    26     $errors = 0, 
    27     $warnings = 0; 
     15    $printer        = null, 
     16    $options        = array(), 
     17    $startTime      = 0, 
     18    $file           = null, 
     19    $actualFiles    = 0, 
     20    $failedFiles    = 0, 
     21    $actualTests    = 0, 
     22    $failedTests    = 0, 
     23    $expected       = array(), 
     24    $passed         = array(), 
     25    $failed         = array(), 
     26    $errors         = array(), 
     27    $warnings       = array(), 
     28    $line           = array(); 
    2829 
    2930  public function __construct(LimePrinter $printer, array $options = array()) 
     
    3637  } 
    3738 
    38   public function start($file) 
    39   { 
    40     $this->close(); 
    41  
     39  public function supportsThreading() 
     40  { 
     41    return true; 
     42  } 
     43 
     44  public function focus($file) 
     45  { 
    4246    $this->file = $file; 
    43     $this->expected = 0; 
    44     $this->passed = 0; 
    45     $this->failed = 0; 
    46     $this->errors = 0; 
    47     $this->warnings = 0; 
    48   } 
    49  
    50   protected function close() 
     47 
     48    if (!array_key_exists($file, $this->line)) 
     49    { 
     50      $this->line[$file] = count($this->line); 
     51      $this->expected[$file] = 0; 
     52      $this->passed[$file] = 0; 
     53      $this->failed[$file] = 0; 
     54      $this->errors[$file] = 0; 
     55      $this->warnings[$file] = 0; 
     56    } 
     57  } 
     58 
     59  public function close() 
    5160  { 
    5261    if (!is_null($this->file)) 
    5362    { 
    5463      $this->actualFiles++; 
    55       $this->actualTests += $this->passed + $this->failed; 
    56       $this->failedTests += $this->failed; 
    57  
    58       $actual = $this->passed+$this->failed; 
    59       $incomplete = ($this->expected > 0 && $actual != $this->expected); 
     64      $this->actualTests += $this->getActual(); 
     65      $this->failedTests += $this->getFailed(); 
    6066 
    6167      $this->printer->printText(str_pad($this->getTruncatedFile(), 73, '.')); 
    6268 
    63       if ($this->errors || $this->failed || $incomplete) 
     69      $incomplete = ($this->getExpected() > 0 && $this->getActual() != $this->getExpected()); 
     70 
     71      if ($this->getErrors() || $this->getFailed() || $incomplete) 
    6472      { 
    6573        $this->failedFiles++; 
    66         $this->printer->printLine('not ok', LimePrinter::NOT_OK); 
    67       } 
    68       else if ($this->warnings
    69       { 
    70         $this->printer->printLine('warning', LimePrinter::WARNING); 
     74        $this->printer->printLine("not ok", LimePrinter::NOT_OK); 
     75      } 
     76      else if ($this->getWarnings()
     77      { 
     78        $this->printer->printLine("warning", LimePrinter::WARNING); 
    7179      } 
    7280      else 
    7381      { 
    74         $this->printer->printLine('ok', LimePrinter::OK); 
    75       } 
    76  
    77       if ($this->errors || $this->warnings || $this->failed
     82        $this->printer->printLine("ok", LimePrinter::OK); 
     83      } 
     84 
     85      if ($this->getErrors() || $this->getWarnings() || $this->getFailed()
    7886      { 
    7987        $this->printer->printText('    '); 
    80         $this->printer->printText('Passed: '.$this->passed); 
    81         $this->printer->printText(str_repeat(' ', 6 - strlen($this->passed))); 
    82         $this->printer->printText('Failed: '.$this->failed, $this->failed > 0 ? LimePrinter::NOT_OK : null); 
    83         $this->printer->printText(str_repeat(' ', 6 - strlen($this->failed))); 
    84         $this->printer->printText('Warnings: '.$this->warnings, $this->warnings > 0 ? LimePrinter::WARNING : null); 
    85         $this->printer->printText(str_repeat(' ', 6 - strlen($this->warnings))); 
    86         $this->printer->printLine('Errors: '.$this->errors, $this->errors > 0 ? LimePrinter::NOT_OK : null); 
    87       } 
    88  
    89       if ($this->errors || $this->warnings || $this->failed || $incomplete) 
    90       { 
    91         $messages = LimeOutputConsoleDetailed::getMessages($actual
    92             $this->expected, $this->passed, $this->errors, $this->warnings); 
     88        $this->printer->printText('Passed: '.$this->getPassed()); 
     89        $this->printer->printText(str_repeat(' ', 6 - strlen($this->getPassed()))); 
     90        $this->printer->printText('Failed: '.$this->getFailed(), $this->getFailed() > 0 ? LimePrinter::NOT_OK : null); 
     91        $this->printer->printText(str_repeat(' ', 6 - strlen($this->getFailed()))); 
     92        $this->printer->printText('Warnings: '.$this->getWarnings(), $this->getWarnings() > 0 ? LimePrinter::WARNING : null); 
     93        $this->printer->printText(str_repeat(' ', 6 - strlen($this->getWarnings()))); 
     94        $this->printer->printLine('Errors: '.$this->getErrors(), $this->getErrors() > 0 ? LimePrinter::NOT_OK : null); 
     95      } 
     96 
     97      if ($this->getErrors() || $this->getWarnings() || $this->getFailed() || $incomplete) 
     98      { 
     99        $messages = LimeOutputConsoleDetailed::getMessages($this->getActual()
     100            $this->getExpected(), $this->getPassed(), $this->getErrors(), $this->getWarnings()); 
    93101 
    94102        foreach ($messages as $message) 
     
    101109  } 
    102110 
     111  protected function getExpected() 
     112  { 
     113    return $this->expected[$this->file]; 
     114  } 
     115 
     116  protected function getActual() 
     117  { 
     118    return $this->getPassed() + $this->getFailed(); 
     119  } 
     120 
     121  protected function getPassed() 
     122  { 
     123    return $this->passed[$this->file]; 
     124  } 
     125 
     126  protected function getFailed() 
     127  { 
     128    return $this->failed[$this->file]; 
     129  } 
     130 
     131  protected function getErrors() 
     132  { 
     133    return $this->errors[$this->file]; 
     134  } 
     135 
     136  protected function getWarnings() 
     137  { 
     138    return $this->warnings[$this->file]; 
     139  } 
     140 
     141  protected function setCursor() 
     142  { 
     143    for ($i = count($this->line); $i > $this->line[$this->file]; --$i) 
     144    { 
     145      $this->printer->previousLine(); 
     146    } 
     147  } 
     148 
     149  protected function resetCursor() 
     150  { 
     151    for ($i = $this->line[$this->file]; $i < count($this->line); ++$i) 
     152    { 
     153      $this->printer->nextLine(); 
     154    } 
     155  } 
     156 
    103157  public function plan($amount) 
    104158  { 
    105     $this->expected = $amount; 
     159    $this->expected[$this->file] = $amount; 
    106160  } 
    107161 
    108162  public function pass($message, $file, $line) 
    109163  { 
    110     $this->passed++; 
    111  
    112     $this->update(); 
     164    $this->passed[$this->file]++; 
    113165  } 
    114166 
    115167  public function fail($message, $file, $line, $error = null) 
    116168  { 
    117     $this->failed++; 
    118  
    119     $this->update(); 
     169    $this->failed[$this->file]++; 
    120170  } 
    121171 
     
    128178  public function warning($message, $file, $line) 
    129179  { 
    130     $this->warnings++; 
     180    $this->warnings[$this->file]++; 
    131181  } 
    132182 
    133183  public function error(Exception $exception) 
    134184  { 
    135     $this->errors++; 
     185    $this->errors[$this->file]++; 
    136186  } 
    137187 
     
    140190  public function flush() 
    141191  { 
    142     $this->close(); 
    143  
    144192    if ($this->failedFiles > 0) 
    145193    { 
     
    161209  } 
    162210 
    163   protected function update() 
    164   { 
    165     if ($this->errors || $this->failed) 
    166     { 
    167       $style = LimePrinter::NOT_OK; 
    168     } 
    169     else if ($this->warnings) 
    170     { 
    171       $style = LimePrinter::WARNING; 
     211  protected function getTruncatedFile() 
     212  { 
     213    if (!is_null($this->options)) 
     214    { 
     215      return str_replace($this->options['base_dir'], '', $this->file); 
    172216    } 
    173217    else 
    174218    { 
    175       $style = LimePrinter::OK; 
    176     } 
    177  
    178     $tests = $this->passed + $this->failed; 
    179  
    180     $this->printer->printText(str_pad($this->getTruncatedFile(), 73, '.')); 
    181     $this->printer->printText($tests."\r", $style); 
    182   } 
    183  
    184   protected function getTruncatedFile() 
    185   { 
    186     if (!is_null($this->options)) 
    187     { 
    188       return str_replace($this->options['base_dir'], '', $this->file); 
    189     } 
    190     else 
    191     { 
    192219      return $this->file; 
    193220    } 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputCoverage.php

    r20975 r21230  
    1212class LimeOutputCoverage implements LimeOutputInterface 
    1313{ 
    14   public function start($file) 
     14  public function supportsThreading() 
     15  { 
     16    return false; 
     17  } 
     18 
     19  public function focus($file) 
    1520  { 
    1621    xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); 
     
    2126    echo serialize(xdebug_get_code_coverage()); 
    2227  } 
     28 
     29  public function close() {} 
    2330 
    2431  public function plan($amount) {} 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputInterface.php

    r20975 r21230  
    1212interface LimeOutputInterface 
    1313{ 
    14   public function start($file); 
     14  public function supportsThreading(); 
     15 
     16  public function focus($file); 
     17 
     18  public function close(); 
    1519 
    1620  public function plan($amount); 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputNone.php

    r20975 r21230  
    1212class LimeOutputNone implements LimeOutputInterface 
    1313{ 
    14   public function start($file) {} 
     14  public function supportsThreading() 
     15  { 
     16    return true; 
     17  } 
     18 
     19  public function focus($file) {} 
     20 
     21  public function close() {} 
    1522 
    1623  public function plan($amount) {} 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputPipe.php

    r20974 r21230  
    1616    $error = false, 
    1717    $buffer = '', 
    18     $output = null; 
     18    $output = null, 
     19    $shell = null, 
     20    $file = null, 
     21    $handle = null, 
     22    $done = true; 
    1923 
    2024  public function __construct(LimeOutputInterface $output, array $suppressedMethods = array()) 
     
    2226    $this->output = $output; 
    2327    $this->suppressedMethods = $suppressedMethods; 
     28    $this->shell = new LimeShell(); 
     29  } 
     30 
     31  public function getConnectedFile() 
     32  { 
     33    return $this->file; 
    2434  } 
    2535 
     
    2838    $arguments['output'] = 'raw'; 
    2939 
     40    $this->file = $file; 
    3041    $this->buffer = ''; 
     42    $this->done = false; 
     43    $this->handle = $this->shell->spawn($file, $arguments); 
     44  } 
    3145 
    32     $shell = new LimeShell(); 
    33     $shell->executeCallback(array($this, 'unserializeLines'), $file, $arguments); 
     46  public function proceed() 
     47  { 
     48    $this->unserializeLines(fread($this->handle, 2048)); 
    3449 
    35     if (!empty($this->buffer)) 
     50    if (feof($this->handle)) 
    3651    { 
    37       $this->output->warning("Could not parse test output. Make sure you don't echo any additional data.", $file, 1); 
     52      if (!empty($this->buffer)) 
     53      { 
     54        $this->output->warning("Could not parse test output. Make sure you don't echo any additional data.", $this->file, 1); 
     55      } 
     56 
     57      $this->done = true; 
    3858    } 
    3959  } 
    4060 
    41   public function unserializeLines($lines) 
     61  public function done() 
     62  { 
     63    return $this->done; 
     64  } 
     65 
     66  protected function unserializeLines($lines) 
    4267  { 
    4368    $this->buffer .= $lines; 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputRaw.php

    r20975 r21230  
    2525  } 
    2626 
    27   public function start($file
     27  public function supportsThreading(
    2828  { 
    29     $this->printCall('start', array($file)); 
     29    return true; 
     30  } 
     31 
     32  public function focus($file) 
     33  { 
     34    $this->printCall('focus', array($file)); 
     35  } 
     36 
     37  public function close() 
     38  { 
     39    $this->printCall('close', array()); 
    3040  } 
    3141 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputXml.php

    r20975 r21230  
    2020  } 
    2121 
    22   public function start($file
     22  public function supportsThreading(
    2323  { 
    24     return $this->output->start($file); 
     24    return $this->output->supportsThreading(); 
     25  } 
     26 
     27  public function focus($file) 
     28  { 
     29    return $this->output->focus($file); 
     30  } 
     31 
     32  public function close($file) 
     33  { 
     34    return $this->output->close($file); 
    2535  } 
    2636 
  • tools/lime/branches/2.0-experimental/test/unit/LimePrinterTest.php

    r20975 r21230  
    5151  $result = ob_get_clean(); 
    5252  // assertions 
    53   $t->todo('asdf', 3); 
    5453  $t->is($result, "<RED>My text</RED>\n", 'The result was colorized and printed'); 
    5554 
  • tools/lime/branches/2.0-experimental/test/unit/LimeShellTest.php

    r20981 r21230  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(9); 
     16$t = new LimeTest(6); 
    1717 
    1818 
     
    7878 
    7979 
    80 // @Test: PHP scripts can be executed with a callback being called on each output 
    81  
    82   // fixtures 
    83   $mock = LimeMock::create('Dummy', $t); 
    84   $mock->callback("Hello World!"); 
    85   $mock->callback("Foo\nBar"); 
    86   $mock->callback(''); 
    87   $mock->replay(); 
    88   file_put_contents($file, <<<EOF 
    89 <?php 
    90 echo "Hello World!"; 
    91 sleep(1); 
    92 echo "Foo\nBar"; 
    93 exit(1); 
    94 EOF 
    95 ); 
    96   // test 
    97   list($returnValue, $output) = $shell->executeCallback(array($mock, 'callback'), $file); 
    98   // assertions 
    99   $mock->verify(); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputArrayTest.php

    r20390 r21230  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(1); 
     16$t = new LimeTest(2); 
    1717 
    1818// @Before 
     
    8787  ); 
    8888  // test 
    89   $output->start('/test/file1'); 
     89  $output->focus('/test/file1'); 
    9090  $output->plan(3); 
    9191  $output->pass('Test message 1', '/test/file1', 11); 
    9292  $output->fail('Test message 2', '/test/file1', 22); 
    93   $output->start('/test/file2'); 
     93  $output->focus('/test/file2'); 
    9494  $output->plan(2); 
    9595  $output->fail('Test message 3', '/test/file2', 33, 'error message'); 
     
    9898  // assertions 
    9999  $t->is($output->toArray(), $expected, 'The array is correct'); 
     100 
     101 
     102// @Test: The array is constructed correctly when switching focus 
     103 
     104  // fixtures 
     105  $expected = array( 
     106    array( 
     107      'file' => '/test/file1', 
     108      'tests' => array( 
     109        1 => array( 
     110          'line' => 11, 
     111          'file' => '/test/file1', 
     112          'message' => 'Test message 1', 
     113          'status' => true, 
     114        ), 
     115        2 => array( 
     116          'line' => 22, 
     117          'file' => '/test/file1', 
     118          'message' => 'Test message 2', 
     119          'status' => false, 
     120        ), 
     121      ), 
     122      'stats' => array( 
     123        'plan' => 3, 
     124        'total' => 2, 
     125        'failed' => array(2), 
     126        'passed' => array(1), 
     127        'skipped' => array(), 
     128      ), 
     129    ), 
     130    array( 
     131      'file' => '/test/file2', 
     132      'tests' => array( 
     133        1 => array( 
     134          'line' => 33, 
     135          'file' => '/test/file2', 
     136          'message' => 'Test message 3', 
     137          'status' => false, 
     138          'error' => 'error message', 
     139        ), 
     140        2 => array( 
     141          'line' => 44, 
     142          'file' => '/test/file2', 
     143          'message' => 'Test message 4', 
     144          'status' => true, 
     145        ), 
     146        3 => array( 
     147          'line' => 55, 
     148          'file' => '/test/file2', 
     149          'message' => 'Test message 5', 
     150          'status' => true, 
     151        ), 
     152      ), 
     153      'stats' => array( 
     154        'plan' => 2, 
     155        'total' => 3, 
     156        'failed' => array(1), 
     157        'passed' => array(2), 
     158        'skipped' => array(3), 
     159      ), 
     160    ), 
     161  ); 
     162  // test 
     163  $output->focus('/test/file1'); 
     164  $output->plan(3); 
     165  $output->pass('Test message 1', '/test/file1', 11); 
     166  $output->focus('/test/file2'); 
     167  $output->plan(2); 
     168  $output->fail('Test message 3', '/test/file2', 33, 'error message'); 
     169  $output->pass('Test message 4', '/test/file2', 44); 
     170  $output->focus('/test/file1'); 
     171  $output->fail('Test message 2', '/test/file1', 22); 
     172  $output->focus('/test/file2'); 
     173  $output->skip('Test message 5', '/test/file2', 55); 
     174  // assertions 
     175  $t->is($output->toArray(), $expected, 'The array is correct'); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleDetailedTest.php

    r20976 r21230  
    2828 
    2929 
    30 // @Test: start() prints the filename 
     30// @Test: focus() prints the filename 
    3131 
    3232  $printer->printLine('# /test/file', LimePrinter::INFO); 
    3333  $printer->replay(); 
    3434  // test 
    35   $output->start('/test/file'); 
     35  $output->focus('/test/file'); 
    3636  // assertions 
    3737  $printer->verify(); 
     
    4545  $printer->replay(); 
    4646  // test 
    47   $output->start('/test/file'); 
     47  $output->focus('/test/file'); 
    4848  // assertions 
    4949  $printer->verify(); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleSummaryTest.php

    r20978 r21230  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(79); 
     16$t = new LimeTest(37); 
    1717 
    1818 
     
    2929 
    3030 
    31 // @Test: The number of tests is updated on every input 
    32  
    33   // fixtures 
    34   $printer->printText(str_pad('/test/script', 73, '.')); 
    35   $printer->printText("1\r", LimePrinter::OK); 
    36   $printer->printText(str_pad('/test/script', 73, '.')); 
    37   $printer->printText("2\r", LimePrinter::OK); 
    38   $printer->printText(str_pad('/test/script', 73, '.')); 
    39   $printer->printText("3\r", LimePrinter::OK); 
    40   $printer->replay(); 
    41   // test 
    42   $output->start('/test/script'); 
    43   $output->pass('A passed test', '/test/script', 11); 
    44   $output->pass('A passed test', '/test/script', 22); 
    45   $output->pass('A passed test', '/test/script', 33); 
    46   // assertions 
    47   $printer->verify(); 
    48  
    49  
    50 // @Test: Once any test has failed, the style of the number is LimePrinter::NOT_OK 
    51  
    52   // fixtures 
    53   $printer->printText(str_pad('/test/script', 73, '.')); 
    54   $printer->printText("1\r", LimePrinter::OK); 
    55   $printer->printText(str_pad('/test/script', 73, '.')); 
    56   $printer->printText("2\r", LimePrinter::NOT_OK); 
    57   $printer->printText(str_pad('/test/script', 73, '.')); 
    58   $printer->printText("3\r", LimePrinter::NOT_OK); 
    59   $printer->replay(); 
    60   // test 
    61   $output->start('/test/script'); 
    62   $output->pass('A passed test', '/test/script', 11); 
    63   $output->fail('A failed test', '/test/script', 22); 
    64   $output->pass('A passed test', '/test/script', 33); 
    65   // assertions 
    66   $printer->verify(); 
    67  
    68  
    69 // @Test: Once a warning has appeared, the style of the number is LimePrinter::WARNING 
    70  
    71   // fixtures 
    72   $printer->printText(str_pad('/test/script', 73, '.')); 
    73   $printer->printText("1\r", LimePrinter::OK); 
    74   $printer->printText(str_pad('/test/script', 73, '.')); 
    75   $printer->printText("2\r", LimePrinter::WARNING); 
    76   $printer->replay(); 
    77   // test 
    78   $output->start('/test/script'); 
    79   $output->pass('A passed test', '/test/script', 11); 
    80   $output->warning('A warning', '/test/script', 22); 
    81   $output->pass('A passed test', '/test/script', 33); 
    82   // assertions 
    83   $printer->verify(); 
    84  
    85  
    86 // @Test: Once an error has appeared, the style of the number is LimePrinter::NOT_OK 
    87  
    88   // fixtures 
    89   $printer->printText(str_pad('/test/script', 73, '.')); 
    90   $printer->printText("1\r", LimePrinter::OK); 
    91   $printer->printText(str_pad('/test/script', 73, '.')); 
    92   $printer->printText("2\r", LimePrinter::NOT_OK); 
    93   $printer->replay(); 
    94   // test 
    95   $output->start('/test/script'); 
     31// @Test: When close() is called, the test summary is printed 
     32 
     33  // fixtures 
     34  $printer->printText(str_pad('/test/script', 73, '.')); 
     35  $printer->printLine("ok", LimePrinter::OK); 
     36  $printer->replay(); 
     37  // test 
     38  $output->focus('/test/script'); 
     39  $output->pass('A passed test', '/test/script', 11); 
     40  $output->close(); 
     41  // assertions 
     42  $printer->verify(); 
     43 
     44 
     45// @Test: When close() is called and tests failed, the status is "not ok" 
     46 
     47  // fixtures 
     48  $printer->printText(str_pad('/test/script', 73, '.')); 
     49  $printer->printLine("not ok", LimePrinter::NOT_OK); 
     50  $printer->any('printText'); 
     51  $printer->any('printLine'); 
     52  $printer->replay(); 
     53  // test 
     54  $output->focus('/test/script'); 
     55  $output->fail('A failed test', '/test/script', 11); 
     56  $output->close(); 
     57  // assertions 
     58  $printer->verify(); 
     59 
     60 
     61// @Test: When close() is called and warnings appeared in the test, the status is warning 
     62 
     63  // fixtures 
     64  $printer->printText(str_pad('/test/script', 73, '.')); 
     65  $printer->printLine("warning", LimePrinter::WARNING); 
     66  $printer->any('printText'); 
     67  $printer->any('printLine'); 
     68  $printer->replay(); 
     69  // test 
     70  $output->focus('/test/script'); 
     71  $output->pass('A passed test', '/test/script', 11); 
     72  $output->warning('A warning', '/test/script', 33); 
     73  $output->close(); 
     74  // assertions 
     75  $printer->verify(); 
     76 
     77 
     78// @Test: When close() is called and errors appeared in the test, the status is "not ok" 
     79 
     80  // fixtures 
     81  $printer->printText(str_pad('/test/script', 73, '.')); 
     82  $printer->printLine("not ok", LimePrinter::NOT_OK); 
     83  $printer->any('printText'); 
     84  $printer->any('printLine'); 
     85  $printer->replay(); 
     86  // test 
     87  $output->focus('/test/script'); 
    9688  $output->pass('A passed test', '/test/script', 11); 
    9789  $output->error(new LimeError('An error', '/test/script', 22)); 
    98   $output->pass('A passed test', '/test/script', 33); 
    99   // assertions 
    100   $printer->verify(); 
    101  
    102  
    103 // @Test: If both a warning and an error appeared, the style is LimePrinter::NOT_OK 
    104  
    105   // fixtures 
    106   $printer->printText(str_pad('/test/script', 73, '.')); 
    107   $printer->printText("1\r", LimePrinter::OK); 
    108   $printer->printText(str_pad('/test/script', 73, '.')); 
    109   $printer->printText("2\r", LimePrinter::NOT_OK); 
    110   $printer->replay(); 
    111   // test 
    112   $output->start('/test/script'); 
    113   $output->pass('A passed test', '/test/script', 11); 
    114   $output->error(new LimeError('An error', '/test/script', 22)); 
    115   $output->warning('A warning', '/test/script', 33); 
    116   $output->pass('A passed test', '/test/script', 44); 
    117   // assertions 
    118   $printer->verify(); 
    119  
    120  
    121 // @Test: When start() is called again, a new line for the new test is started 
    122  
    123   // fixtures 
    124   $printer->printText(str_pad('/test/script', 73, '.')); 
    125   $printer->printText("1\r", LimePrinter::OK); 
    126   $printer->printText(str_pad('/test/script', 73, '.')); 
    127   $printer->printLine("ok", LimePrinter::OK); 
    128   $printer->replay(); 
    129   // test 
    130   $output->start('/test/script'); 
    131   $output->pass('A passed test', '/test/script', 11); 
    132   $output->start('/test/script2'); 
    133   // assertions 
    134   $printer->verify(); 
    135  
    136  
    137 // @Test: When start() is called again and tests failed, the status is "not ok" 
    138  
    139   // fixtures 
    140   $printer->printText(str_pad('/test/script', 73, '.')); 
    141   $printer->printText("1\r", LimePrinter::NOT_OK); 
    142   $printer->printText(str_pad('/test/script', 73, '.')); 
    143   $printer->printLine("not ok", LimePrinter::NOT_OK); 
    144   $printer->any('printText'); 
    145   $printer->any('printLine'); 
    146   $printer->replay(); 
    147   // test 
    148   $output->start('/test/script'); 
    149   $output->fail('A failed test', '/test/script', 11); 
    150   $output->start('/test/script2'); 
    151   // assertions 
    152   $printer->verify(); 
    153  
    154  
    155 // @Test: When start() is called again and warnings appeared in the test, the status is warning 
    156  
    157   // fixtures 
    158   $printer->printText(str_pad('/test/script', 73, '.')); 
    159   $printer->printText("1\r", LimePrinter::OK); 
    160   $printer->printText(str_pad('/test/script', 73, '.')); 
    161   $printer->printLine("warning", LimePrinter::WARNING); 
    162   $printer->any('printText'); 
    163   $printer->any('printLine'); 
    164   $printer->replay(); 
    165   // test 
    166   $output->start('/test/script'); 
    167   $output->pass('A passed test', '/test/script', 11); 
    168   $output->warning('A warning', '/test/script', 33); 
    169   $output->start('/test/script2'); 
    170   // assertions 
    171   $printer->verify(); 
    172  
    173  
    174 // @Test: When start() is called again and errors appeared in the test, the status is "not ok" 
    175  
    176   // fixtures 
    177   $printer->printText(str_pad('/test/script', 73, '.')); 
    178   $printer->printText("1\r", LimePrinter::OK); 
    179   $printer->printText(str_pad('/test/script', 73, '.')); 
    180   $printer->printLine("not ok", LimePrinter::NOT_OK); 
    181   $printer->any('printText'); 
    182   $printer->any('printLine'); 
    183   $printer->replay(); 
    184   // test 
    185   $output->start('/test/script'); 
    186   $output->pass('A passed test', '/test/script', 11); 
    187   $output->error(new LimeError('An error', '/test/script', 22)); 
    188   $output->start('/test/script2'); 
    189   // assertions 
    190   $printer->verify(); 
    191  
    192  
    193 // @Test: When start() is called again, the styles are reset 
    194  
    195   // fixtures 
    196   $printer->printText(str_pad('/test/script', 73, '.')); 
    197   $printer->printText("1\r", LimePrinter::OK); 
    198   $printer->printText(str_pad('/test/script', 73, '.')); 
    199   $printer->printLine("not ok", LimePrinter::NOT_OK); 
    200   $printer->any('printText'); 
    201   $printer->any('printLine'); 
    202   $printer->printText(str_pad('/test/script2', 73, '.')); 
    203   $printer->printText("1\r", LimePrinter::OK); 
    204   $printer->replay(); 
    205   // test 
    206   $output->start('/test/script'); 
    207   $output->pass('A passed test', '/test/script', 11); 
    208   $output->error(new LimeError('An error', '/test/script', 22)); 
    209   $output->start('/test/script2'); 
    210   $output->pass('A passed test', '/test/script2', 11); 
    211   // assertions 
    212   $printer->verify(); 
    213  
    214  
    215 // @Test: When start() is called again and the plan did not match, a message is printed 
    216  
    217   // fixtures 
    218   $printer->printText(str_pad('/test/script', 73, '.')); 
    219   $printer->printText("1\r", LimePrinter::OK); 
     90  $output->close(); 
     91  // assertions 
     92  $printer->verify(); 
     93 
     94 
     95// @Test: When close() is called and the plan did not match, a message is printed 
     96 
     97  // fixtures 
    22098  $printer->printText(str_pad('/test/script', 73, '.')); 
    22199  $printer->printLine("not ok", LimePrinter::NOT_OK); 
     
    223101  $printer->replay(); 
    224102  // test 
    225   $output->start('/test/script'); 
     103  $output->focus('/test/script'); 
    226104  $output->plan(2); 
    227105  $output->pass('A passed test', '/test/script', 11); 
    228   $output->start('/test/script2'); 
    229   // assertions 
    230   $printer->verify(); 
    231  
    232  
    233 // @Test: When start() is called again and anything failed, detailed statistics are printed 
     106  $output->close(); 
     107  // assertions 
     108  $printer->verify(); 
     109 
     110 
     111// @Test: When close() is called and anything failed, detailed statistics are printed 
    234112 
    235113  // fixtures 
     
    247125  $printer->replay(); 
    248126  // test 
    249   $output->start('/test/script'); 
     127  $output->focus('/test/script'); 
    250128  $output->pass('A passed test', '/test/script', 11); 
    251129  $output->fail('A failed test', '/test/script', 11); 
     
    254132  $output->error(new LimeError('An error', '/test/script', 11)); 
    255133  $output->error(new LimeError('An error', '/test/script', 11)); 
    256   $output->start('/test/script2'); 
     134  $output->close(); 
    257135  // assertions 
    258136  $printer->verify(); 
     
    269147  $output = new LimeOutputConsoleSummary($printer); 
    270148  // test 
    271   $output->start('/test/script1'); 
    272   $output->pass('A passed test', '/test/script', 11); 
    273   $output->start('/test/script2'); 
     149  $output->focus('/test/script1'); 
     150  $output->pass('A passed test', '/test/script', 11); 
     151  $output->close(); 
     152  $output->focus('/test/script2'); 
    274153  $output->pass('A passed test', '/test/script2', 11); 
    275154  $output->warning('A warning', '/test/script2', 11); 
    276   $output->start('/test/script3'); 
     155  $output->close(); 
     156  $output->focus('/test/script3'); 
    277157  $output->fail('A failed test', '/test/script3', 11); 
    278   $output->start('/test/script4'); 
     158  $output->close(); 
     159  $output->focus('/test/script4'); 
    279160  $output->pass('A passed test', '/test/script', 11); 
    280161  $output->error(new LimeError('An error', '/test/script', 11)); 
    281   $output->start('/test/script5'); 
    282   $output->pass('A passed test', '/test/script', 11); 
     162  $output->close(); 
     163  $output->focus('/test/script5'); 
     164  $output->pass('A passed test', '/test/script', 11); 
     165  $output->close(); 
    283166  $output->flush(); 
    284167  // assertions 
     
    297180  $output = new LimeOutputConsoleSummary($printer); 
    298181  // test 
    299   $output->start('/test/script1'); 
     182  $output->focus('/test/script1'); 
    300183  $output->pass('A passed test', '/test/script1', 11); 
    301   $output->start('/test/script2'); 
     184  $output->close(); 
     185  $output->focus('/test/script2'); 
    302186  $output->pass('A passed test', '/test/script2', 11); 
    303187  $output->pass('A passed test', '/test/script2', 11); 
     188  $output->close(); 
    304189  $output->flush(); 
    305190  // assertions 
     
    313198  $printer->reset(); 
    314199  $printer->printText(str_pad('/script', 73, '.')); 
    315   $printer->printText("1\r", LimePrinter::OK); 
    316   $printer->replay(); 
    317   // test 
    318   $output->start('/test/script'); 
    319   $output->pass('A passed test', '/test/script', 11); 
    320   // assertions 
    321   $printer->verify(); 
     200  $printer->printLine("ok", LimePrinter::OK); 
     201  $printer->replay(); 
     202  // test 
     203  $output->focus('/test/script'); 
     204  $output->pass('A passed test', '/test/script', 11); 
     205  $output->close(); 
     206  // assertions 
     207  $printer->verify(); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputInspectableTest.php

    r20975 r21230  
    7979  // fixtures 
    8080  $mock = LimeMock::create('LimeOutputInterface', $t); 
    81   $mock->start('/test/file'); 
     81  $mock->focus('/test/file'); 
    8282  $mock->pass('A passed test', '/test/script', 11); 
    8383  $mock->fail('A failed test', '/test/script', 11, 'The error'); 
     
    9191  $output = new LimeOutputInspectable($mock); 
    9292  // test 
    93   $output->start('/test/file'); 
     93  $output->focus('/test/file'); 
    9494  $output->pass('A passed test', '/test/script', 11); 
    9595  $output->fail('A failed test', '/test/script', 11, 'The error'); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputPipeTest.php

    r20974 r21230  
    4343  // test 
    4444  $connector->connect($file); 
     45  while (!$connector->done()) $connector->proceed(); 
    4546  // assertions 
    4647  $output->verify(); 
     
    5960  // test 
    6061  $connector->connect($file); 
     62  while (!$connector->done()) $connector->proceed(); 
    6163  // assertions 
    6264  $output->verify(); 
     
    7880  // test 
    7981  $connector->connect($file); 
     82  while (!$connector->done()) $connector->proceed(); 
    8083  // assertions 
    8184  $output->verify(); 
     
    9497  // test 
    9598  $connector->connect($file); 
     99  while (!$connector->done()) $connector->proceed(); 
    96100  // assertions 
    97101  $output->verify(); 
     
    111115  // test 
    112116  $connector->connect($file); 
     117  while (!$connector->done()) $connector->proceed(); 
    113118  // assertions 
    114119  $output->verify(); 
     
    129134  // test 
    130135  $connector->connect($file); 
     136  while (!$connector->done()) $connector->proceed(); 
    131137  // assertions 
    132138  $output->verify(); 
     
    148154  // test 
    149155  $connector->connect($file); 
     156  while (!$connector->done()) $connector->proceed(); 
    150157  // assertions 
    151158  $output->verify(); 
     
    163170  // test 
    164171  $connector->connect($file); 
     172  while (!$connector->done()) $connector->proceed(); 
    165173  // assertions 
    166174  $output->verify(); 
     
    175183  // test 
    176184  $connector->connect($file); 
     185  while (!$connector->done()) $connector->proceed(); 
    177186  // assertions 
    178187  $output->verify(); 
     
    189198  // test 
    190199  $connector->connect($file); 
     200  while (!$connector->done()) $connector->proceed(); 
    191201  // assertions 
    192202  $output->verify(); 
     
    202212  // test 
    203213  $connector->connect($file); 
    204   // assertions 
    205   $output->verify(); 
     214  while (!$connector->done()) $connector->proceed(); 
     215  // assertions 
     216  $output->verify(); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputRawTest.php

    r20975 r21230  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(11); 
     16$t = new LimeTest(12); 
    1717 
    1818 
     
    2727 
    2828 
    29 // @Test: start() prints the method call as serialized array 
     29// @Test: focus() prints the method call as serialized array 
    3030 
    3131  // test 
    3232  ob_start(); 
    33   $output->start('/test/file'); 
     33  $output->focus('/test/file'); 
    3434  $result = ob_get_clean(); 
    3535  // assertions 
    36   $t->is($result, serialize(array('start', array('/test/file')))."\n", 'The method call is serialized'); 
     36  $t->is($result, serialize(array('focus', array('/test/file')))."\n", 'The method call is serialized'); 
     37 
     38 
     39// @Test: close() prints the method call as serialized array 
     40 
     41  // test 
     42  ob_start(); 
     43  $output->close(); 
     44  $result = ob_get_clean(); 
     45  // assertions 
     46  $t->is($result, serialize(array('close', array()))."\n", 'The method call is serialized'); 
    3747 
    3848