Changeset 20488
- Timestamp:
- 07/25/09 12:45:57 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/lime/branches/2.0-experimental/lib/LimeHarness.php
r20482 r20488 66 66 sort($this->files); 67 67 68 $connector = new LimeOutputPipe($this->output );68 $connector = new LimeOutputPipe($this->output, array('start', 'flush')); 69 69 70 70 foreach ($this->files as $file) 71 71 { 72 $this->output->start($file); 72 73 $connector->connect($file); 73 74 } tools/lime/branches/2.0-experimental/lib/output/LimeOutputPipe.php
r20482 r20488 13 13 { 14 14 protected 15 $suppressedMethods = array(), 15 16 $error = false, 16 17 $buffer = '', 17 18 $output = null; 18 19 19 public function __construct(LimeOutputInterface $output )20 public function __construct(LimeOutputInterface $output, array $suppressedMethods = array()) 20 21 { 21 22 $this->output = $output; 23 $this->suppressedMethods = $suppressedMethods; 22 24 } 23 25 … … 63 65 } 64 66 65 if ( $method != 'flush')67 if (!in_array($method, $this->suppressedMethods)) 66 68 { 67 69 foreach ($arguments as &$argument) … … 78 80 79 81 $this->buffer = implode("\n", $lines); 82 83 while (!empty($this->buffer)) 84 { 85 if (preg_match('/^\s*([\w\s]+)(: .+) in (.+) on line (\d+)/', $this->buffer, $matches)) 86 { 87 $this->buffer = trim(substr($this->buffer, strlen($matches[0]))); 88 89 if ($matches[1] == 'Warning') 90 { 91 $this->output->warning($matches[1].$matches[2], $matches[3], $matches[4]); 92 } 93 else 94 { 95 $this->output->error($matches[1].$matches[2], $matches[3], $matches[4]); 96 } 97 98 // consume Xdebug call stack 99 while (preg_match('/^(Call Stack:|\d\.\d+\s+\d+\s+\d+\.\s+.+:\d+)/', $this->buffer, $matches)) 100 { 101 $this->buffer = trim(substr($this->buffer, strlen($matches[0]))); 102 } 103 } 104 else 105 { 106 break; 107 } 108 } 80 109 } 81 110 tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputPipeTest.php
r20482 r20488 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest( 9);16 $t = new LimeTest(12); 17 17 18 18 … … 82 82 83 83 84 // @Test: The call to flush() is NOT passed84 // @Test: Method calls can be suppressed by passing the first constructor parameter 85 85 86 86 // fixtures 87 $output-> flush()->never();87 $output->invoke('pass')->never(); 88 88 $output->replay(); 89 $connector = new LimeOutputPipe($output, array('pass')); 89 90 file_put_contents($file, <<<EOF 90 91 <?php 91 echo serialize(array(" flush", array()))."\n";92 echo serialize(array("pass", array("A passed test", "/test/file", 11)))."\n"; 92 93 EOF 93 94 ); … … 158 159 $connector->connect($file); 159 160 161 162 // @Test: A PHP error is passed to error() - invalid identifier 163 164 // @Test: Case 1 - Invalid identifier 165 166 // fixtures 167 $output->error("Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$'", $file, 1); 168 $output->replay(); 169 file_put_contents($file, '<?php $1invalidname;'); 170 // test 171 $connector->connect($file); 172 // assertions 173 $output->verify(); 174 175 176 // @Test: Case 2 - Failed require 177 178 // fixtures 179 $output->warning("Warning: require(foobar.php): failed to open stream: No such file or directory", $file, 1); 180 $output->error("Fatal error: require(): Failed opening required 'foobar.php' (include_path='".get_include_path()."')", $file, 1); 181 $output->replay(); 182 file_put_contents($file, '<?php require "foobar.php";'); 183 // test 184 $connector->connect($file); 185 // assertions 186 $output->verify();