[limb-svn] r6515 - in 3.x/trunk/limb/tests_runner: src tests/cases
svn at limb-project.com
svn at limb-project.com
Sat Nov 10 14:52:05 MSK 2007
Author: pachanga
Date: 2007-11-10 14:52:05 +0300 (Sat, 10 Nov 2007)
New Revision: 6515
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6515
Modified:
3.x/trunk/limb/tests_runner/src/lmbTestOptions.class.php
3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
3.x/trunk/limb/tests_runner/src/lmbTestTreeFileNode.class.php
3.x/trunk/limb/tests_runner/tests/cases/lmbTestShellUITest.class.php
Log:
-- test class filter added, can be used as follows:
$ limb_unit --tests Foo,Bar some_tests.php
Modified: 3.x/trunk/limb/tests_runner/src/lmbTestOptions.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestOptions.class.php 2007-11-10 11:09:13 UTC (rev 6514)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestOptions.class.php 2007-11-10 11:52:05 UTC (rev 6515)
@@ -17,11 +17,11 @@
*/
class lmbTestOptions
{
- static protected $valid_keys = array('file_filter',
- 'methods_filter',
- 'groups_filter',
- 'verbose');
- static protected $options = array();
+ static protected $options = array('file_filter' => LIMB_TESTS_RUNNER_FILE_FILTER,
+ 'tests_filter' => array(),
+ 'methods_filter' => array(),
+ 'groups_filter' => array(),
+ 'verbose' => false);
static protected $has_defaults = false;
static function set($name, $value)
@@ -46,17 +46,14 @@
if(self :: $has_defaults)
return;
- self :: $options = array('file_filter' => LIMB_TESTS_RUNNER_FILE_FILTER,
- 'methods_filter' => array(),
- 'groups_filter' => array(),
- 'verbose' => false);
+ //???
self :: $has_defaults = true;
}
static protected function _check($key)
{
- if(!in_array($key, self :: $valid_keys))
+ if(!in_array($key, array_keys(self :: $options)))
throw new Exception("Test option '$key' is not supported");
}
}
Modified: 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php 2007-11-10 11:09:13 UTC (rev 6514)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestShellUI.class.php 2007-11-10 11:52:05 UTC (rev 6515)
@@ -68,6 +68,8 @@
'*Test.class.php;*test.php;*Test.php' by default.
-G, --groups=group1[,group2] Comma separated list of test groups defined in annotations
tags which should be executed(e.g @group group1,group2)
+ -T, --tests=Foo[,Bar] Comma separated list of test classes which should be
+ executed
-M, --methods=testFoo[,testBar] Comma separated list of test methods which should be
executed
-C, --cover='path1;path2' Sets paths delimitered with ';' which should be analyzed
@@ -115,14 +117,14 @@
static function getShortOpts()
{
- return 'hvI:c:C:M:G:';
+ return 'hvI:c:C:T:M:G:';
}
static function getLongOpts()
{
return array('help', 'version', 'include=', 'config=',
'cover=', 'cover-report=', 'cover-exclude=',
- 'methods=', 'groups=');
+ 'tests=', 'methods=', 'groups=');
}
function run()
@@ -188,6 +190,10 @@
case '--groups':
lmbTestOptions :: set('groups_filter', array_map('trim', explode(',', trim($option[1]))));
break;
+ case 'T':
+ case '--tests':
+ lmbTestOptions :: set('tests_filter', array_map('trim', explode(',', trim($option[1]))));
+ break;
case 'M':
case '--methods':
lmbTestOptions :: set('methods_filter', array_map('trim', explode(',', trim($option[1]))));
Modified: 3.x/trunk/limb/tests_runner/src/lmbTestTreeFileNode.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/src/lmbTestTreeFileNode.class.php 2007-11-10 11:09:13 UTC (rev 6514)
+++ 3.x/trunk/limb/tests_runner/src/lmbTestTreeFileNode.class.php 2007-11-10 11:52:05 UTC (rev 6515)
@@ -41,6 +41,14 @@
return $matches[1];
}
+ protected function _isClassFiltered($class)
+ {
+ $filter = lmbTestOptions :: get('tests_filter');
+ if(!$filter)
+ return false;
+ return !in_array($class, $filter);
+ }
+
protected function _isClassGroupFiltered($class)
{
if(!$groups = lmbTestOptions :: get('groups_filter'))
@@ -62,14 +70,21 @@
return true;
}
+ protected function _isFiltered($class)
+ {
+ return $this->_isClassFiltered($class) ||
+ $this->_isClassGroupFiltered($class);
+ }
+
protected function _prepareTestCase($test)
{
require_once($this->file);
$candidates = $this->_getClassesDefinedInFile();
+
$loader = new SimpleFileLoader();
foreach($loader->selectRunnableTests($candidates) as $class)
{
- if($this->_isClassGroupFiltered($class))
+ if($this->_isFiltered($class))
continue;
$case = new $class();
Modified: 3.x/trunk/limb/tests_runner/tests/cases/lmbTestShellUITest.class.php
===================================================================
--- 3.x/trunk/limb/tests_runner/tests/cases/lmbTestShellUITest.class.php 2007-11-10 11:09:13 UTC (rev 6514)
+++ 3.x/trunk/limb/tests_runner/tests/cases/lmbTestShellUITest.class.php 2007-11-10 11:52:05 UTC (rev 6515)
@@ -97,6 +97,20 @@
$this->assertNoPattern('~Error~i', $screen);
}
+ function testPerformOnlySelectedTests()
+ {
+ $foo = $this->_createTestCase($foo_file = LIMB_VAR_DIR . '/cases/foo_test.php');
+ $bar = $this->_createTestCase($bar_file = LIMB_VAR_DIR . '/cases/bar_test.php');
+ $zoo = $this->_createTestCase($zoo_file = LIMB_VAR_DIR . '/cases/zoo_test.php');
+
+ $ret = $this->_execScript("--tests=" . $foo->getClass(). "," . $zoo->getClass(). " $foo_file $bar_file $zoo_file", $screen);
+ if(!$this->assertEqual($ret, 0))
+ echo $screen;
+
+ $this->assertPattern('~1\s+of\s+2\s+done\(' . $foo->getClass() . '\)~', $screen);
+ $this->assertPattern('~2\s+of\s+2\s+done\(' . $zoo->getClass() . '\)~', $screen);
+ }
+
function testPerformOnlySelectedMethods()
{
$foo_body = '%class_header%';
More information about the limb-svn
mailing list