Skip to content
Extraits de code Groupes Projets
Valider cddc4227 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #6633 support multiple arguments

parent 742bd8cc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -28,7 +28,7 @@ class TestsRun extends ConsoleCommand ...@@ -28,7 +28,7 @@ class TestsRun extends ConsoleCommand
{ {
$this->setName('tests:run'); $this->setName('tests:run');
$this->setDescription('Run Piwik PHPUnit tests one testsuite after the other'); $this->setDescription('Run Piwik PHPUnit tests one testsuite after the other');
$this->addArgument('magic', InputArgument::OPTIONAL, 'Eg a path to a file or directory, the name of a testsuite, the name of a plugin, ... We will try to detect what you meant.', ''); $this->addArgument('variables', InputArgument::IS_ARRAY, 'Eg a path to a file or directory, the name of a testsuite, the name of a plugin, ... We will try to detect what you meant. You can define multiple values', array());
$this->addOption('options', 'o', InputOption::VALUE_OPTIONAL, 'All options will be forwarded to phpunit', ''); $this->addOption('options', 'o', InputOption::VALUE_OPTIONAL, 'All options will be forwarded to phpunit', '');
$this->addOption('xhprof', null, InputOption::VALUE_NONE, 'Profile using xhprof.'); $this->addOption('xhprof', null, InputOption::VALUE_NONE, 'Profile using xhprof.');
$this->addOption('group', null, InputOption::VALUE_REQUIRED, 'Run only a specific test group. Separate multiple groups by comma, for instance core,plugins', ''); $this->addOption('group', null, InputOption::VALUE_REQUIRED, 'Run only a specific test group. Separate multiple groups by comma, for instance core,plugins', '');
...@@ -40,7 +40,7 @@ class TestsRun extends ConsoleCommand ...@@ -40,7 +40,7 @@ class TestsRun extends ConsoleCommand
{ {
$options = $input->getOption('options'); $options = $input->getOption('options');
$groups = $input->getOption('group'); $groups = $input->getOption('group');
$magic = $input->getArgument('magic'); $magics = $input->getArgument('variables');
$groups = $this->getGroupsFromString($groups); $groups = $this->getGroupsFromString($groups);
...@@ -88,15 +88,23 @@ class TestsRun extends ConsoleCommand ...@@ -88,15 +88,23 @@ class TestsRun extends ConsoleCommand
$suite = $this->getTestsuite($input); $suite = $this->getTestsuite($input);
$testFile = $this->getTestFile($input); $testFile = $this->getTestFile($input);
if (!empty($magic)) { if (!empty($magics)) {
if (empty($suite) && (in_array($magic, $this->getTestsSuites()) || in_array($magic, array('plugin', 'core')))) { foreach ($magics as $magic) {
$suite = $this->buildTestSuiteName($magic); if (empty($suite) && (in_array($magic, $this->getTestsSuites()))) {
} elseif (empty($testFile) && file_exists($magic)) { $suite = $this->buildTestSuiteName($magic);
$testFile = $this->fixPathToTestFileOrDirectory($magic); } elseif (empty($testFile) && 'core' === $magic) {
} elseif (empty($testFile) && $this->getPluginTestFolderName($magic)) { $testFile = $this->fixPathToTestFileOrDirectory('tests/PHPUnit');
$testFile = $this->getPluginTestFolderName($magic); } elseif (empty($testFile) && 'plugins' === $magic) {
} elseif (empty($groups)) { $testFile = $this->fixPathToTestFileOrDirectory('plugins');
$groups = $this->getGroupsFromString($magic); } elseif (empty($testFile) && file_exists($magic)) {
$testFile = $this->fixPathToTestFileOrDirectory($magic);
} elseif (empty($testFile) && $this->getPluginTestFolderName($magic)) {
$testFile = $this->getPluginTestFolderName($magic);
} elseif (empty($groups)) {
$groups = $this->getGroupsFromString($magic);
} else {
$groups[] = $magic;
}
} }
} }
...@@ -159,7 +167,7 @@ class TestsRun extends ConsoleCommand ...@@ -159,7 +167,7 @@ class TestsRun extends ConsoleCommand
$params = $this->buildPhpUnitCliParams($suite, $groups, $options); $params = $this->buildPhpUnitCliParams($suite, $groups, $options);
if (!empty($testFile)) { if (!empty($testFile)) {
$params .= $params . " " . $testFile; $params = $params . " " . $testFile;
} }
$this->executeTestRun($command, $params, $output); $this->executeTestRun($command, $params, $output);
...@@ -264,4 +272,4 @@ class TestsRun extends ConsoleCommand ...@@ -264,4 +272,4 @@ class TestsRun extends ConsoleCommand
return $groups; return $groups;
} }
} }
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter