Development

Changeset 21237

You must first sign up to be able to contribute.

Changeset 21237

Show
Ignore:
Timestamp:
08/18/09 22:25:16 (5 years ago)
Author:
bschussek
Message:

Renamed LimeOutputConsoleDetailed? to LimeOutputTap? and moved plan to the bottom to improve TAP compliancy when multiple test script results are displayed

Files:

Legend:

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

    r21235 r21237  
    4343      $colorizer->setStyle(self::HAPPY, array('fg' => 'white', 'bg' => 'green', 'bold' => true)); 
    4444      $colorizer->setStyle(self::STRING, array('fg' => 'cyan')); 
    45       $colorizer->setStyle(self::NUMBER, array('fg' => 'cyan')); 
     45      $colorizer->setStyle(self::NUMBER, array()); 
    4646      $colorizer->setStyle(self::BOOLEAN, array('fg' => 'cyan')); 
    4747      $colorizer->setStyle(self::INFO, array('fg' => 'cyan', 'bold' => true)); 
  • tools/lime/branches/2.0-experimental/lib/LimeTest.php

    r21230 r21237  
    3232    $this->options = array( 
    3333      'base_dir'     => null, 
    34       'output'       => 'detail', 
     34      'output'       => 'tap', 
    3535      'force_colors' => false, 
    3636      'verbose'      => false, 
  • tools/lime/branches/2.0-experimental/lib/LimeTestSuite.php

    r21230 r21237  
    5151    if ($this->options['processes'] > 1 && !$output->supportsThreading()) 
    5252    { 
    53       throw new LogicException(sprintf('The output "%s" does not support threading', $type)); 
     53      throw new LogicException(sprintf('The output "%s" does not support multi-processing', $type)); 
    5454    } 
    5555 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleSummary.php

    r21231 r21237  
    104104      if ($this->getErrors() || $this->getWarnings() || $this->getFailed() || $incomplete) 
    105105      { 
    106         $messages = LimeOutputConsoleDetailed::getMessages($this->getActual(), 
     106        $messages = LimeOutputTap::getMessages($this->getActual(), 
    107107            $this->getExpected(), $this->getPassed(), $this->getErrors(), $this->getWarnings()); 
    108108 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputFactory.php

    r20968 r21237  
    3030      case 'summary': 
    3131        return new LimeOutputConsoleSummary($printer, $this->options); 
    32       case 'detail': 
     32      case 'tap': 
    3333      default: 
    34         return new LimeOutputConsoleDetailed($printer, $this->options); 
     34        return new LimeOutputTap($printer, $this->options); 
    3535    } 
    3636  } 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputTap.php

    • Property svn:mergeinfo set
    r21230 r21237  
    1010 */ 
    1111 
    12 class LimeOutputConsoleDetailed implements LimeOutputInterface 
     12class LimeOutputTap implements LimeOutputInterface 
    1313{ 
    1414  protected 
     
    1919    $warnings   = 0, 
    2020    $errors     = 0, 
     21    $file       = null, 
    2122    $printer    = null; 
    2223 
     
    4243  public function focus($file) 
    4344  { 
    44     $this->printer->printLine('# '.$this->stripBaseDir($file), LimePrinter::INFO); 
     45    if ($this->file !== $file) 
     46    { 
     47      $this->printer->printLine('# '.$this->stripBaseDir($file), LimePrinter::INFO); 
     48 
     49      $this->file = $file; 
     50    } 
    4551  } 
    4652 
     
    5258  { 
    5359    $this->expected += $amount; 
    54     $this->printer->printLine('1..'.$amount); 
    5560  } 
    5661 
     
    258263    if (is_null($this->expected)) 
    259264    { 
    260       $this->plan($this->actual, null); 
    261     } 
     265      $this->plan($this->actual); 
     266    } 
     267 
     268    $this->printer->printLine('1..'.$this->expected); 
    262269 
    263270    $messages = self::getMessages($this->actual, $this->expected, $this->passed, $this->errors, $this->warnings); 
  • tools/lime/branches/2.0-experimental/test/unit/LimeAnnotationSupportTest.php

    r20975 r21237  
    7373  $expected = <<<EOF 
    7474$root/@$file 
    75 1..0 
    76 Before 
    77 Test 1 
    78 Before 
    79 Test 2 
     75Before 
     76Test 1 
     77Before 
     78Test 2 
     791..0 
    8080 Looks like everything went fine. 
    8181EOF; 
     
    9191  $expected = <<<EOF 
    9292$root/@$file 
    93 1..0 
    9493Test 1 
    9594After 
    9695Test 2 
    9796After 
     971..0 
    9898 Looks like everything went fine. 
    9999EOF; 
     
    109109  $expected = <<<EOF 
    110110$root/@$file 
    111 1..0 
    112111Before All 
    113112Test 1 
    114113Test 2 
     1141..0 
    115115 Looks like everything went fine. 
    116116EOF; 
     
    126126  $expected = <<<EOF 
    127127$root/@$file 
    128 1..0 
    129128Test 1 
    130129Test 2 
    131130After All 
     1311..0 
    132132 Looks like everything went fine. 
    133133EOF; 
     
    143143  $expected = <<<EOF 
    144144$root/@$file 
    145 1..0 
    146145Before annotation 
    147146Before 
    148147Test 
     1481..0 
    149149 Looks like everything went fine. 
    150150EOF; 
     
    160160  $expected = <<<EOF 
    161161$root/@$file 
    162 1..0 
    163162Try is not matched 
    164163If is not matched 
     1641..0 
    165165 Looks like everything went fine. 
    166166EOF 
     
    177177  $expected = <<<EOF 
    178178$root/@$file 
    179 1..0 
    180179Test 
     1801..0 
    181181 Looks like everything went fine. 
    182182EOF 
     
    201201  $expected = <<<EOF 
    202202$root/@$file 
    203 1..0 
    204203Before 
    205204BeforeTest 
    206205BeforeTestAfter 
     2061..0 
    207207 Looks like everything went fine. 
    208208EOF; 
     
    218218  $expected = <<<EOF 
    219219$root/@$file 
    220 1..0 
    221220Global 
    222221GlobalBefore 
    223222GlobalBeforeTest 
    224223GlobalBeforeTestAfter 
     2241..0 
    225225 Looks like everything went fine. 
    226226EOF; 
     
    235235  $expected = <<<EOF 
    236236$root/@$file 
    237 1..0 
    238237Is not set 
    239238Is not set 
     2391..0 
    240240 Looks like everything went fine. 
    241241EOF; 
     
    251251  $expected = <<<EOF 
    252252$root/@$file 
    253 1..0 
    254253Test 1 
    255254# This test is commented with "double" and 'single' quotes 
    256255Test 2 
     2561..0 
    257257 Looks like everything went fine. 
    258258EOF; 
     
    268268  $expected = '/'.str_replace('%ANY%', '.*', preg_quote(<<<EOF 
    269269$root/@$file 
    270 1..4 
    271270Test 1 
    272271not ok 1 - A "RuntimeException" was thrown 
     
    283282Test 4 
    284283ok 4 - A "RuntimeException" with code "1" was thrown 
     2841..4 
    285285 Looks like you failed 2 tests of 4. 
    286286EOF 
     
    297297  $expected = '/'.str_replace('%ANY%', '.*', preg_quote(<<<EOF 
    298298$root/@$file 
    299 1..3 
    300299Test 1 
    301300ok 1 - A "RuntimeException" with code "0" was thrown 
     
    307306Test 3 
    308307ok 3 - A "RuntimeException" with code "1" was thrown 
     3081..3 
    309309 Looks like you failed 1 tests of 3. 
    310310EOF 
     
    321321  $expected = '/'.str_replace('%ANY%', '.*', preg_quote(<<<EOF 
    322322$root/@$file 
    323 1..2 
    324323Test 1 
    325324ok 1 - A "RuntimeException" was thrown 
     
    329328#            got: none 
    330329#       expected: LogicException 
     3301..2 
    331331 Looks like you failed 1 tests of 2. 
    332332EOF 
     
    343343  $expected = <<<EOF 
    344344$root/@$file 
    345 1..0 
    346345Test 1 
    347346Test 3 
     3471..0 
    348348 Looks like everything went fine. 
    349349EOF; 
     
    410410  $expected = <<<EOF 
    411411$root/@$file 
    412 1..0 
    413412Test 
     4131..0 
    414414 Looks like everything went fine. 
    415415EOF; 
     
    425425  $expected = <<<EOF 
    426426$root/@$file 
    427 1..0 
    428 Before 
    429 Test 1 
    430 Before 
    431 Test 2 
    432  Looks like everything went fine. 
    433 EOF; 
    434   $t->is($result, 0, 'The file returned exit status 0 (success)'); 
    435   $t->isOutput($actual, $expected); 
     427Before 
     428Test 1 
     429Before 
     430Test 2 
     4311..0 
     432 Looks like everything went fine. 
     433EOF; 
     434  $t->is($result, 0, 'The file returned exit status 0 (success)'); 
     435  $t->isOutput($actual, $expected); 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputTapTest.php

    • Property svn:mergeinfo set
    r21230 r21237  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(64); 
     16$t = new LimeTest(74); 
    1717 
    1818// @Before 
    1919 
    2020  $printer = LimeMock::createStrict('LimePrinter', $t); 
    21   $output = new LimeOutputConsoleDetailed($printer); 
     21  $output = new LimeOutputTap($printer); 
    2222 
    2323 
     
    3838 
    3939 
     40// @Test: focus() prints the filename only once 
     41 
     42  $printer->printLine('# /test/file', LimePrinter::INFO)->once(); 
     43  $printer->replay(); 
     44  // test 
     45  $output->focus('/test/file'); 
     46  $output->focus('/test/file'); 
     47  // assertions 
     48  $printer->verify(); 
     49 
     50 
    4051// @Test: The constructor accepts a base directory which is stripped from the file name 
    4152 
    4253  // fixtures 
    43   $output = new LimeOutputConsoleDetailed($printer, array('base_dir' => '/test')); 
     54  $output = new LimeOutputTap($printer, array('base_dir' => '/test')); 
    4455  $printer->printLine('# /file', LimePrinter::INFO); 
    4556  $printer->replay(); 
    4657  // test 
    4758  $output->focus('/test/file'); 
    48   // assertions 
    49   $printer->verify(); 
    50  
    51  
    52 // @Test: plan() prints the test file and the amount of planned tests 
    53  
    54   // fixtures 
    55   $printer->printLine('1..2'); 
    56   $printer->replay(); 
    57   // test 
    58   $output->plan(2, '/test/file'); 
    5959  // assertions 
    6060  $printer->verify(); 
     
    121121 
    122122  // fixtures 
    123   $output = new LimeOutputConsoleDetailed($printer, array('base_dir' => '/test')); 
     123  $output = new LimeOutputTap($printer, array('base_dir' => '/test')); 
    124124  $printer->printLine('not ok 1', LimePrinter::NOT_OK); 
    125125  $printer->printLine('#     Failed test (/file at line 11)', LimePrinter::COMMENT); 
     
    205205 
    206206  // fixtures 
    207   $output = new LimeOutputConsoleDetailed($printer, array('base_dir' => '/test')); 
     207  $output = new LimeOutputTap($printer, array('base_dir' => '/test')); 
    208208  $printer->printLargeBox("A very important warning\n(in /file on line 11)", LimePrinter::WARNING); 
    209209  $printer->replay(); 
     
    231231 
    232232  // fixtures 
    233   $output = new LimeOutputConsoleDetailed($printer, array('base_dir' => '/test')); 
     233  $output = new LimeOutputTap($printer, array('base_dir' => '/test')); 
    234234  $printer->printLargeBox("LimeError: A very important error\n(in /file on line 11)", LimePrinter::ERROR); 
    235235  $printer->printLine('Exception trace:', LimePrinter::COMMENT); 
     
    265265 
    266266 
    267 // @Test: flush() prints a summary 
     267// @Test: flush() prints the plan and a summary 
    268268 
    269269  // @Test: Case 1 - Too many tests 
     
    274274  $output->pass('Second test', '/test/file', 22); 
    275275  $printer->reset(); 
     276  $printer->printLine('1..1'); 
    276277  $printer->printBox(' Looks like you planned 1 tests but ran 1 extra.', LimePrinter::ERROR); 
    277278  $printer->replay(); 
     
    288289  $output->fail('Second test', '/test/file', 22); 
    289290  $printer->reset(); 
     291  $printer->printLine('1..1'); 
    290292  $printer->printBox(' Looks like you failed 1 tests of 2.', LimePrinter::ERROR); 
    291293  $printer->printBox(' Looks like you planned 1 tests but ran 1 extra.', LimePrinter::ERROR); 
     
    302304  $output->pass('First test', '/test/file', 11); 
    303305  $printer->reset(); 
     306  $printer->printLine('1..2'); 
    304307  $printer->printBox(' Looks like you planned 2 tests but only ran 1.', LimePrinter::ERROR); 
    305308  $printer->replay(); 
     
    315318  $output->pass('First test', '/test/file', 11); 
    316319  $printer->reset(); 
     320  $printer->printLine('1..1'); 
    317321  $printer->printBox(' Looks like everything went fine.', LimePrinter::HAPPY); 
    318322  $printer->replay(); 
     
    330334  $output->pass('Third test', '/test/file', 33); 
    331335  $printer->reset(); 
     336  $printer->printLine('1..3'); 
    332337  $printer->printBox(' Looks like you failed 1 tests of 3.', LimePrinter::ERROR); 
    333338  $printer->replay(); 
     
    344349  $output->fail('Second test', '/test/file', 22); 
    345350  $printer->reset(); 
     351  $printer->printLine('1..3'); 
    346352  $printer->printBox(' Looks like you failed 1 tests of 2.', LimePrinter::ERROR); 
    347353  $printer->printBox(' Looks like you planned 3 tests but only ran 2.', LimePrinter::ERROR); 
     
    371377  $output->skip('First test', '/test/file', 11); 
    372378  $printer->reset(); 
     379  $printer->printLine('1..1'); 
    373380  $printer->printBox(' Looks like everything went fine.', LimePrinter::HAPPY); 
    374381  $printer->replay(); 
     
    385392  $output->warning('Some warning', '/test/file', 11); 
    386393  $printer->reset(); 
     394  $printer->printLine('1..1'); 
    387395  $printer->printBox(' Looks like you\'re nearly there.', LimePrinter::WARNING); 
    388396  $printer->replay(); 
     
    399407  $output->error(new LimeError('Some error', '/test/file', 11)); 
    400408  $printer->reset(); 
     409  $printer->printLine('1..1'); 
    401410  $printer->printBox(' Looks like some errors occurred.', LimePrinter::ERROR); 
    402411  $printer->replay(); 
     
    414423  $output->pass('Second test', '/test/file', 11); 
    415424  $printer->reset(); 
     425  $printer->printLine('1..2'); 
    416426  $printer->printBox(' Looks like everything went fine.', LimePrinter::HAPPY); 
    417427  $printer->replay();