Ticket #151: tasks_ext_phpunit_FormatterStuff-152.patch
| File tasks_ext_phpunit_FormatterStuff-152.patch, 6.8 kB (added by dirk.thomas@4wdmedia.de, 1 year ago) |
|---|
-
phpunit3/PHPUnit3ResultFormatter.php
old new 37 37 38 38 protected $project = NULL; 39 39 40 private $timer = NULL; 41 42 private $runCount = 0; 40 private $timers = false; 43 41 44 private $ failureCount = 0;42 private $runCounts = false; 45 43 46 private $ errorCount = 0;44 private $failureCounts = false; 47 45 46 private $errorCounts = false; 47 48 private $incompleteCounts = false; 49 50 private $skipCounts = false; 51 48 52 /** 49 53 * Sets the writer the formatter is supposed to write its results to. 50 54 */ … … 80 84 81 85 function startTestRun() 82 86 { 87 $this->timers = array($this->getMicrotime()); 88 $this->runCounts = array(0); 89 $this->failureCounts = array(0); 90 $this->errorCounts = array(0); 91 $this->incompleteCounts = array(0); 92 $this->skipCounts = array(0); 83 93 } 84 94 85 95 function endTestRun() … … 88 98 89 99 function startTestSuite(PHPUnit_Framework_TestSuite $suite) 90 100 { 91 $this-> runCount = 0;92 $this-> failureCount= 0;93 $this-> errorCount= 0;94 95 $this-> timer = new Timer();96 $this-> timer->start();101 $this->timers[] = $this->getMicrotime(); 102 $this->runCounts[] = 0; 103 $this->failureCounts[] = 0; 104 $this->errorCounts[] = 0; 105 $this->incompleteCounts[] = 0; 106 $this->skipCounts[] = 0; 97 107 } 98 108 99 109 function endTestSuite(PHPUnit_Framework_TestSuite $suite) 100 110 { 101 $this->timer->stop(); 111 $lastRunCount = array_pop($this->runCounts); 112 $this->runCounts[count($this->runCounts) - 1] += $lastRunCount; 113 114 $lastFailureCount = array_pop($this->failureCounts); 115 $this->failureCounts[count($this->failureCounts) - 1] += $lastFailureCount; 116 117 $lastErrorCount = array_pop($this->errorCounts); 118 $this->errorCounts[count($this->errorCounts) - 1] += $lastErrorCount; 119 120 $lastIncompleteCount = array_pop($this->incompleteCounts); 121 $this->incompleteCounts[count($this->incompleteCounts) - 1] += $lastIncompleteCount; 122 123 $lastSkipCount = array_pop($this->skipCounts); 124 $this->skipCounts[count($this->skipCounts) - 1] += $lastSkipCount; 125 126 array_pop($this->timers); 102 127 } 103 128 104 129 function startTest(PHPUnit_Framework_Test $test) 105 130 { 106 $this->runCount ++;131 $this->runCounts[count($this->runCounts) - 1]++; 107 132 } 108 133 109 134 function endTest(PHPUnit_Framework_Test $test, $time) … … 112 137 113 138 function addError(PHPUnit_Framework_Test $test, Exception $e, $time) 114 139 { 115 $this->errorCount ++;140 $this->errorCounts[count($this->errorCounts) - 1]++; 116 141 } 117 142 118 143 function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) 119 144 { 120 $this->failureCount ++;145 $this->failureCounts[count($this->failureCounts) - 1]++; 121 146 } 122 147 123 148 function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) 124 149 { 150 $this->incompleteCounts[count($this->incompleteCounts) - 1]++; 125 151 } 126 152 127 153 function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) 128 154 { 155 $this->skipCounts[count($this->skipCounts) - 1]++; 129 156 } 130 157 131 158 function getRunCount() 132 159 { 133 return $this->runCount;160 return end($this->runCounts); 134 161 } 135 162 136 163 function getFailureCount() 137 164 { 138 return $this->failureCount;165 return end($this->failureCounts); 139 166 } 140 167 141 168 function getErrorCount() 142 169 { 143 return $this->errorCount;170 return end($this->errorCounts); 144 171 } 145 172 173 function getIncompleteCount() 174 { 175 return end($this->incompleteCounts); 176 } 177 178 function getSkippedCount() 179 { 180 return end($this->skipCounts); 181 } 182 146 183 function getElapsedTime() 147 184 { 148 if ( $this->timer)185 if (end($this->timers)) 149 186 { 150 return $this-> timer->getElapsedTime();187 return $this->getMicrotime() - end($this->timers); 151 188 } 152 189 else 153 190 { 154 191 return 0; 155 192 } 156 193 } 194 195 private function getMicrotime() { 196 list($usec, $sec) = explode(' ', microtime()); 197 return (float)$usec + (float)$sec; 198 } 157 199 } 158 200 ?> -
phpunit3/PlainPHPUnit3ResultFormatter.php
old new 52 52 53 53 function endTestSuite(PHPUnit_Framework_TestSuite $suite) 54 54 { 55 parent::endTestSuite($suite);56 57 55 $sb = "Testsuite: " . $suite->getName() . "\n"; 58 56 $sb.= "Tests run: " . $this->getRunCount(); 59 57 $sb.= ", Failures: " . $this->getFailureCount(); 60 58 $sb.= ", Errors: " . $this->getErrorCount(); 61 $sb.= ", Time elapsed: " . $this->getElapsedTime(); 62 $sb.= " sec\n"; 59 $sb.= ", Incomplete: " . $this->getIncompleteCount(); 60 $sb.= ", Skipped: " . $this->getSkippedCount(); 61 $sb.= ", Time elapsed: " . sprintf('%0.5f', $this->getElapsedTime()) . " s\n"; 63 62 63 parent::endTestSuite($suite); 64 64 65 if ($this->out != NULL) 65 66 { 66 67 $this->out->write($sb); … … 85 86 { 86 87 parent::addIncompleteTest($test, $e, $time); 87 88 88 $this->formatError("INCOMPLETE", $test , $e);89 $this->formatError("INCOMPLETE", $test); 89 90 } 90 91 91 private function formatError($type, PHPUnit_Framework_Test $test, Exception $e)92 function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) 92 93 { 94 parent::addSkippedTest($test, $e, $time); 95 $this->formatError("SKIPPED", $test); 96 } 97 98 private function formatError($type, PHPUnit_Framework_Test $test, Exception $e = null) 99 { 93 100 if ($test != null) 94 101 { 95 102 $this->endTest($test, time()); -
phpunit3/SummaryPHPUnit3ResultFormatter.php
old new 31 31 */ 32 32 class SummaryPHPUnit3ResultFormatter extends PHPUnit3ResultFormatter 33 33 { 34 function endTest Suite(PHPUnit_Framework_TestSuite $suite)34 function endTestRun() 35 35 { 36 parent::endTestSuite($suite);37 38 36 $sb = "Tests run: " . $this->getRunCount(); 39 37 $sb.= ", Failures: " . $this->getFailureCount(); 40 38 $sb.= ", Errors: " . $this->getErrorCount(); 41 $sb.= ", Time elapsed: " . $this->getElapsedTime(); 42 $sb.= " sec\n"; 39 $sb.= ", Incomplete: " . $this->getIncompleteCount(); 40 $sb.= ", Skipped: " . $this->getSkippedCount(); 41 $sb.= ", Time elapsed: " . sprintf('%0.5f', $this->getElapsedTime()) . " s\n"; 43 42 43 parent::endTestRun($suite); 44 44 45 if ($this->out != NULL) 45 46 { 46 47 $this->out->write($sb); -
PHPUnitTestRunner.php
old new 112 112 $this->retCode = self::ERRORS; 113 113 } 114 114 115 else if ($res->failureCount() != 0 || $res->notImplementedCount() != 0 )115 else if ($res->failureCount() != 0 || $res->notImplementedCount() != 0 || $res->skippedCount() != 0) 116 116 { 117 117 $this->retCode = self::FAILURES; 118 118 }
