Permalink
Browse files

Merge pull request #495 from jpic/master

Added --testsuite argument, allowing to filter files/directory by parent testsuite name attribute
  • Loading branch information...
2 parents 5a62ff7 + 34bd4fe commit a4183ff8f7576bc9e37119a40c823476ad1b05ba @edorian edorian committed May 9, 2012
Showing with 20 additions and 5 deletions.
  1. +8 −1 PHPUnit/TextUI/Command.php
  2. +12 −4 PHPUnit/Util/Configuration.php
@@ -86,6 +86,7 @@ class PHPUnit_TextUI_Command
'debug' => NULL,
'exclude-group=' => NULL,
'filter=' => NULL,
+ 'testsuite=' => NULL,
'group=' => NULL,
'help' => NULL,
'include-path=' => NULL,
@@ -344,6 +345,11 @@ protected function handleArguments(array $argv)
}
break;
+ case '--testsuite': {
+ $this->arguments['testsuite'] = $option[1];
+ }
+ break;
+
case '--group': {
$this->arguments['groups'] = explode(',', $option[1]);
}
@@ -657,7 +663,7 @@ class_exists('PHPUnit_Extensions_SeleniumTestCase')) {
}
if (!isset($this->arguments['test'])) {
- $testSuite = $configuration->getTestSuiteConfiguration();
+ $testSuite = $configuration->getTestSuiteConfiguration(isset($this->arguments['testsuite']) ? $this->arguments['testsuite'] : null);
if ($testSuite !== NULL) {
$this->arguments['test'] = $testSuite;
@@ -851,6 +857,7 @@ protected function showHelp()
--testdox-text <file> Write agile documentation in Text format to file.
--filter <pattern> Filter which tests to run.
+ --testsuite <pattern> Filter which testsuite to run.
--group ... Only runs tests from the specified group(s).
--exclude-group ... Exclude tests from the specified group(s).
--list-groups List available test groups.
@@ -758,7 +758,7 @@ public function getSeleniumBrowserConfiguration()
* @return PHPUnit_Framework_TestSuite
* @since Method available since Release 3.2.1
*/
- public function getTestSuiteConfiguration()
+ public function getTestSuiteConfiguration($testSuiteFilter=null)
{
$testSuiteNodes = $this->xpath->query('testsuites/testsuite');
@@ -767,15 +767,15 @@ public function getTestSuiteConfiguration()
}
if ($testSuiteNodes->length == 1) {
- return $this->getTestSuite($testSuiteNodes->item(0));
+ return $this->getTestSuite($testSuiteNodes->item(0), $testSuiteFilter);
}
if ($testSuiteNodes->length > 1) {
$suite = new PHPUnit_Framework_TestSuite;
foreach ($testSuiteNodes as $testSuiteNode) {
$suite->addTestSuite(
- $this->getTestSuite($testSuiteNode)
+ $this->getTestSuite($testSuiteNode, $testSuiteFilter)
);
}
@@ -788,7 +788,7 @@ public function getTestSuiteConfiguration()
* @return PHPUnit_Framework_TestSuite
* @since Method available since Release 3.4.0
*/
- protected function getTestSuite(DOMElement $testSuiteNode)
+ protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter=null)
{
if ($testSuiteNode->hasAttribute('name')) {
$suite = new PHPUnit_Framework_TestSuite(
@@ -807,6 +807,10 @@ protected function getTestSuite(DOMElement $testSuiteNode)
$fileIteratorFacade = new File_Iterator_Facade;
foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) {
+ if ($testSuiteFilter && $directoryNode->parentNode->getAttribute('name') != $testSuiteFilter) {
+ continue;
+ }
+
$directory = (string)$directoryNode->nodeValue;
if (empty($directory)) {
@@ -851,6 +855,10 @@ protected function getTestSuite(DOMElement $testSuiteNode)
}
foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) {
+ if ($testSuiteFilter && $fileNode->parentNode->getAttribute('name') != $testSuiteFilter) {
+ continue;
+ }
+
$file = (string)$fileNode->nodeValue;
if (empty($file)) {

0 comments on commit a4183ff

Please sign in to comment.