[limb-svn] r6925 - 3.x/trunk/limb/tests_runner/src
svn at limb-project.com
svn at limb-project.com
Sat Apr 12 01:43:56 MSD 2008
Author: pachanga
Date: 2008-04-12 01:43:55 +0400 (Sat, 12 Apr 2008)
New Revision: 6925
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6925
Modified:
3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php
3.x/trunk/limb/tests_runner/src/lmbTestShellReporter.class.php
3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
Log:
-- adding lmbTestRunner :: getCurrent() static method which returs current running instance of this class
-- moving time and memory reports into lmbTestShellReporter
-- experimenting with more reporting refactoring
Modified: 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php 2008-04-11 09:30:54 UTC (rev 6924)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestRunner.class.php 2008-04-11 21:43:55 UTC (rev 6925)
@@ -15,18 +15,24 @@
*/
class lmbTestRunner
{
+ static protected $current = null;
+
protected $reporter;
protected $coverage;
protected $coverage_reporter;
protected $coverage_include;
protected $coverage_exclude;
protected $coverage_report_dir;
-
protected $start_time = 0;
protected $end_time = 0;
protected $start_memory_usage = 0;
protected $end_memory_usage = 0;
+ static function getCurrent()
+ {
+ return self :: $current;
+ }
+
function setReporter($reporter)
{
$this->reporter = $reporter;
@@ -47,13 +53,14 @@
{
require_once(dirname(__FILE__) . '/../simpletest.inc.php');
+ self :: $current = $this;
+
$this->_startStats();
$this->_startCoverage();
$res = $this->_doRun($root_node, $path);
$this->_endCoverage();
- $this->_endStats();
return $res;
}
@@ -80,11 +87,13 @@
function getRunTime()
{
+ $this->_endStats();
return round($this->end_time - $this->start_time, 3);
}
function getMemoryUsage()
{
+ $this->_endStats();
$diff = $this->end_memory_usage - $this->start_memory_usage;
if($diff == 0)
return null;
Modified: 3.x/trunk/limb/tests_runner/src/lmbTestShellReporter.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestShellReporter.class.php 2008-04-11 09:30:54 UTC (rev 6924)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestShellReporter.class.php 2008-04-11 21:43:55 UTC (rev 6925)
@@ -15,13 +15,80 @@
*/
class lmbTestShellReporter extends TextReporter
{
+ protected $failed_tests = array();
+
+ function paintGroupStart($test_name, $size)
+ {
+ parent :: paintGroupStart($test_name, $size);
+ }
+
+ function paintGroupEnd($test_name)
+ {
+ parent :: paintGroupEnd($test_name);
+ }
+
+ function paintCaseStart($test_name)
+ {
+ parent :: paintCaseStart($test_name);
+ }
+
function paintCaseEnd($test_name)
{
parent :: paintCaseEnd($test_name);
-
echo $this->getTestCaseProgress() . " of " . $this->getTestCaseCount() . " done({$test_name})\n";
}
-
+
+ function paintMethodStart($test_name)
+ {
+ parent :: paintMethodStart($test_name);
+ }
+
+ function paintMethodEnd($test_name)
+ {
+ parent :: paintMethodEnd($test_name);
+ }
+
+ function paintSkip($message)
+ {
+ parent :: paintSkip($message);
+ }
+
+ function paintHeader($test_name)
+ {
+ parent :: paintHeader($test_name);
+ }
+
+ function paintFooter($test_name)
+ {
+ parent :: paintFooter($test_name);
+
+ $runner = lmbTestRunner :: getCurrent();
+ print 'Tests time: ' . $runner->getRuntime() . " sec.\n";
+ if($memory = $runner->getMemoryUsage())
+ print 'Tests memory usage: ' . $memory . " Mb.\n";
+
+ /*if($this->failed_tests)
+ {
+ print "=========== TESTS HAD ERRORS ===========\n";
+ print "Failed tests: [" . implode(", ", $this->failed_tests) . "]\n";
+ }
+ else
+ print "=========== ALL TESTS PASSED ===========\n";
+ */
+ }
+
+ function paintFail($message)
+ {
+ parent :: paintFail($message);
+ $this->failed_tests[] = $this->_extractFileName($message);
+ }
+
+ function paintError($message)
+ {
+ parent :: paintError($message);
+ $this->failed_tests[] = $this->_extractFileName($message);
+ }
+
function paintException($exception)
{
parent::paintException($exception);
@@ -37,5 +104,12 @@
print "Exception full message:\n";
print $exception->__toString();
}
+
+ protected function _extractFileName($message)
+ {
+ $regex = "~.*\[([^\]]+)\s+line\s+(\d+)\].*~";
+ preg_match($regex, $message, $m);
+ return $m[1];
+ }
}
Modified: 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php 2008-04-11 09:30:54 UTC (rev 6924)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php 2008-04-11 21:43:55 UTC (rev 6925)
@@ -261,11 +261,6 @@
{
$this->_error($e->__toString());
}
-
- echo 'Tests time: ' . $runner->getRuntime() . " sec.\n";
- if($memory = $runner->getMemoryUsage())
- echo 'Tests memory usage: ' . $memory . " Mb.\n";
-
return $res;
}
More information about the limb-svn
mailing list