Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
Added filter option to specify tests to run.
Browse files Browse the repository at this point in the history
Closes #27.
  • Loading branch information
dersam committed Jun 16, 2015
1 parent bef41da commit 4628574
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/LinusShops/Prophet/Commands/Scry.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ protected function configure()
InputOption::VALUE_NONE,
'If set, will display code coverage report'
)
->addOption(
'filter',
'f',
InputOption::VALUE_OPTIONAL,
'Filter test methods by a regular expression'
)
;
}

Expand All @@ -91,6 +97,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
if ($input->getOption('coverage')) {
$cmd .= ' --coverage';
}
if ($input->getOption('filter')) {
$cmd .= ' --filter '.$input->getOption('filter');
}
$this->cli->veryVerbose($cmd, $output);
passthru($cmd);
} else {
Expand Down Expand Up @@ -173,7 +182,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$runner = new TestRunner();
$runner->run(
$path = $input->getOption('path').'/'.$module->getPath(),
$input->getOption('coverage')
$input->getOption('coverage'),
$input->getOption('filter')
);
$dispatcher->dispatch(Events::PROPHET_POSTMODULE, new Events\Module($module));
}
Expand Down
7 changes: 6 additions & 1 deletion src/LinusShops/Prophet/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestRunner
* 1: Tests failed
* 2: Failed with exception
*/
public function run($modulePath, $coverage = false)
public function run($modulePath, $coverage = false, $filter = false)
{
$runner = new \PHPUnit_TextUI_Command();
$options = array(
Expand All @@ -30,6 +30,11 @@ public function run($modulePath, $coverage = false)
$modulePath.'/phpunit.xml'
);

if ($filter !== false) {
$options[] = '--filter';
$options[] = $filter;
}

if ($coverage) {
$options[] = '--coverage-text';
}
Expand Down

0 comments on commit 4628574

Please sign in to comment.