Ticket #420: PHPUnitTask.php.2.patch
| File PHPUnitTask.php.2.patch, 5.4 KB (added by bschultz@…, 2 years ago) |
|---|
-
classes/phing/tasks/ext/phpunit/PHPUnitTask.php
65 65 { 66 66 throw new BuildException("PHPUnitTask requires PHP version >= 5.0.3", $this->getLocation()); 67 67 } 68 68 69 69 /** 70 70 * Determine PHPUnit version number 71 71 */ … … 77 77 { 78 78 throw new BuildException("PHPUnitTask requires PHPUnit version >= 3.2.0", $this->getLocation()); 79 79 } 80 80 81 81 /** 82 82 * Other dependencies that should only be loaded when class is actually used. 83 83 */ … … 92 92 93 93 require_once 'PHPUnit/Framework.php'; 94 94 require_once 'PHPUnit/Util/Filter.php'; 95 95 96 96 // point PHPUnit_MAIN_METHOD define to non-existing method 97 97 if (!defined('PHPUnit_MAIN_METHOD')) 98 98 { 99 99 define('PHPUnit_MAIN_METHOD', 'PHPUnitTask::undefined'); 100 100 } 101 101 102 102 $path = realpath($pwd . '/../../../'); 103 103 PHPUnit_Util_Filter::addDirectoryToFilter($path); 104 104 } 105 105 106 106 /** 107 107 * Sets the name of a bootstrap file that is run before 108 108 * executing the tests … … 113 113 { 114 114 $this->bootstrap = $bootstrap; 115 115 } 116 116 117 117 function setErrorproperty($value) 118 118 { 119 119 $this->errorproperty = $value; 120 120 } 121 121 122 122 function setFailureproperty($value) 123 123 { 124 124 $this->failureproperty = $value; 125 125 } 126 126 127 127 function setIncompleteproperty($value) 128 128 { 129 129 $this->incompleteproperty = $value; 130 130 } 131 131 132 132 function setSkippedproperty($value) 133 133 { 134 134 $this->skippedproperty = $value; 135 135 } 136 136 137 137 function setHaltonerror($value) 138 138 { 139 139 $this->haltonerror = $value; … … 158 158 { 159 159 $this->printsummary = $printsummary; 160 160 } 161 161 162 162 function setCodecoverage($codecoverage) 163 163 { 164 164 $this->codecoverage = $codecoverage; … … 184 184 { 185 185 $token = ' ,;'; 186 186 $this->excludeGroups = array(); 187 $tok = strtok($ groups, $token);187 $tok = strtok($excludeGroups, $token); 188 188 while ($tok !== false) { 189 189 $this->excludeGroups[] = $tok; 190 190 $tok = strtok($token); … … 214 214 } 215 215 216 216 $tests = array(); 217 217 218 218 if ($this->printsummary) 219 219 { 220 220 $fe = new FormatterElement(); … … 222 222 $fe->setUseFile(false); 223 223 $this->formatters[] = $fe; 224 224 } 225 225 226 226 if ($this->bootstrap) 227 227 { 228 228 require_once $this->bootstrap; 229 229 } 230 230 231 231 foreach ($this->formatters as $fe) 232 232 { 233 233 $formatter = $fe->getFormatter(); … … 236 236 if ($fe->getUseFile()) 237 237 { 238 238 $destFile = new PhingFile($fe->getToDir(), $fe->getOutfile()); 239 239 240 240 $writer = new FileWriter($destFile->getAbsolutePath()); 241 241 242 242 $formatter->setOutput($writer); … … 248 248 249 249 $formatter->startTestRun(); 250 250 } 251 251 252 252 foreach ($this->batchtests as $batchtest) 253 253 { 254 254 $this->execute($batchtest->getTestSuite()); 255 } 256 255 } 256 257 257 foreach ($this->formatters as $fe) 258 258 { 259 259 $formatter = $fe->getFormatter(); 260 260 $formatter->endTestRun(); 261 261 } 262 262 263 263 if ($this->testfailed) 264 264 { 265 265 throw new BuildException($this->testfailuremessage); … … 272 272 private function execute($suite) 273 273 { 274 274 $runner = new PHPUnitTestRunner($this->project, $this->groups, $this->excludeGroups); 275 275 276 276 $runner->setCodecoverage($this->codecoverage); 277 277 $runner->setUseCustomErrorHandler($this->usecustomerrorhandler); 278 278 … … 280 280 { 281 281 $formatter = $fe->getFormatter(); 282 282 283 $runner->addFormatter($formatter); 283 $runner->addFormatter($formatter); 284 284 } 285 285 286 286 $runner->run($suite); 287 287 288 288 $retcode = $runner->getRetCode(); 289 289 290 290 if ($retcode == PHPUnitTestRunner::ERRORS) { 291 291 if ($this->errorproperty) { 292 292 $this->project->setNewProperty($this->errorproperty, true); … … 299 299 if ($this->failureproperty) { 300 300 $this->project->setNewProperty($this->failureproperty, true); 301 301 } 302 302 303 303 if ($this->haltonfailure) { 304 304 $this->testfailed = true; 305 305 $this->testfailuremessage = $runner->getLastFailureMessage(); … … 308 308 if ($this->incompleteproperty) { 309 309 $this->project->setNewProperty($this->incompleteproperty, true); 310 310 } 311 311 312 312 if ($this->haltonincomplete) { 313 313 $this->testfailed = true; 314 314 $this->testfailuremessage = $runner->getLastFailureMessage(); … … 317 317 if ($this->skippedproperty) { 318 318 $this->project->setNewProperty($this->skippedproperty, true); 319 319 } 320 320 321 321 if ($this->haltonskipped) { 322 322 $this->testfailed = true; 323 323 $this->testfailuremessage = $runner->getLastFailureMessage();
