Skip to content
Extraits de code Groupes Projets
Valider b91058db rédigé par Matthieu Napoli's avatar Matthieu Napoli
Parcourir les fichiers

Added support for passing any number of arguments to the test command on AWS

parent 157dea89
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -35,9 +35,10 @@ class TestsRunOnAws extends ConsoleCommand ...@@ -35,9 +35,10 @@ class TestsRunOnAws extends ConsoleCommand
{ {
$this->setName('tests:run-aws'); $this->setName('tests:run-aws');
$this->addArgument('testsuite', InputArgument::OPTIONAL, 'Allowed values: ' . implode(', ', $this->allowedTestSuites)); $this->addArgument('testsuite', InputArgument::OPTIONAL, 'Allowed values: ' . implode(', ', $this->allowedTestSuites));
$this->addArgument('arguments', InputArgument::IS_ARRAY, 'Any additional argument will be passed to the test command.');
$this->addOption('launch-only', null, InputOption::VALUE_NONE, 'Only launches an instance and outputs the connection parameters. Useful if you want to connect via SSH.'); $this->addOption('launch-only', null, InputOption::VALUE_NONE, 'Only launches an instance and outputs the connection parameters. Useful if you want to connect via SSH.');
$this->addOption('update-only', null, InputOption::VALUE_NONE, 'Launches an instance, outputs the connection parameters and prepares the instance for a test run but does not actually run the tests. It will also checkout the specified version.'); $this->addOption('update-only', null, InputOption::VALUE_NONE, 'Launches an instance, outputs the connection parameters and prepares the instance for a test run but does not actually run the tests. It will also checkout the specified version.');
$this->addOption('one-instance-per-testsuite', null, InputOption::VALUE_NONE, 'Launches an instance, outputs the connection parameters and prepares the instance for a test run but does not actually run the tests. It will also checkout the specified version.'); $this->addOption('one-instance-per-testsuite', null, InputOption::VALUE_NONE, 'Launches one instance for system tests and one for ui tests.');
$this->addOption('checkout', null, InputOption::VALUE_REQUIRED, 'Git hash, tag or branch to checkout. Defaults to current hash', $this->getCurrentGitHash()); $this->addOption('checkout', null, InputOption::VALUE_REQUIRED, 'Git hash, tag or branch to checkout. Defaults to current hash', $this->getCurrentGitHash());
$this->addOption('patch-file', null, InputOption::VALUE_REQUIRED, 'Apply the given patch file after performing a checkout'); $this->addOption('patch-file', null, InputOption::VALUE_REQUIRED, 'Apply the given patch file after performing a checkout');
$this->setDescription('Run a specific testsuite on AWS'); $this->setDescription('Run a specific testsuite on AWS');
...@@ -57,15 +58,15 @@ If you want to apply a patch on top of the checked out version you can apply the ...@@ -57,15 +58,15 @@ If you want to apply a patch on top of the checked out version you can apply the
<comment>./console tests:run-aws --patch-file=test.patch ui</comment> <comment>./console tests:run-aws --patch-file=test.patch ui</comment>
This will checkout the same revision as you are currently on and then apply the patch. To generate a diff use for instance the command <comment>git diff > test.patch</comment>. This will checkout the same revision as you are currently on and then apply the patch. To generate a diff use for instance the command <comment>git diff > test.patch</comment>.
This feature is still beta and there might be problems with pictures and/or binaries etc. This feature is still beta and there might be problems with pictures and/or binaries etc.
You can also pass any argument to the command and they will be forwarded to the test command, for example to run a specific UI test: <comment>./console tests:run-aws ui Dashboard</comment>.
'); ');
} }
/**
* Execute command like: ./console core:clear-caches
*/
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$testSuite = $this->getTestSuite($input); $testSuite = $this->getTestSuite($input);
$arguments = $input->getArgument('arguments');
$patchFile = $this->getPatchFile($input); $patchFile = $this->getPatchFile($input);
$launchOnly = $input->getOption('launch-only'); $launchOnly = $input->getOption('launch-only');
$updateOnly = $input->getOption('update-only'); $updateOnly = $input->getOption('update-only');
...@@ -102,7 +103,7 @@ This feature is still beta and there might be problems with pictures and/or bina ...@@ -102,7 +103,7 @@ This feature is still beta and there might be problems with pictures and/or bina
return 0; return 0;
} }
$testRunner->runTests($host, $testSuite); $testRunner->runTests($host, $testSuite, $arguments);
$message = $this->buildFinishedMessage($testSuite, $host); $message = $this->buildFinishedMessage($testSuite, $host);
$output->writeln("\n$message\n"); $output->writeln("\n$message\n");
......
...@@ -55,11 +55,11 @@ class Remote ...@@ -55,11 +55,11 @@ class Remote
} }
} }
public function runTests($host, $testSuite) public function runTests($host, $testSuite, array $arguments)
{ {
$this->prepareTestRun($host); $this->prepareTestRun($host);
$this->printVersionInfo(); $this->printVersionInfo();
$this->doRunTests($testSuite); $this->doRunTests($testSuite, $arguments);
} }
private function prepareTestRun($host) private function prepareTestRun($host)
...@@ -74,17 +74,19 @@ class Remote ...@@ -74,17 +74,19 @@ class Remote
$this->ssh->exec('phantomjs --version'); $this->ssh->exec('phantomjs --version');
} }
private function doRunTests($testSuite) private function doRunTests($testSuite, array $arguments)
{ {
$arguments = implode(' ', $arguments);
$this->ssh->exec("ps -ef | grep \"php console tests:run\" | grep -v grep | awk '{print $2}' | xargs kill -9"); $this->ssh->exec("ps -ef | grep \"php console tests:run\" | grep -v grep | awk '{print $2}' | xargs kill -9");
if ('all' === $testSuite) { if ('all' === $testSuite) {
$this->ssh->exec('php console tests:run --options="--colors"'); $this->ssh->exec('php console tests:run --options="--colors" ' . $arguments);
} elseif ('ui' === $testSuite) { } elseif ('ui' === $testSuite) {
$this->ssh->exec('php console tests:run-ui --persist-fixture-data --assume-artifacts'); $this->ssh->exec('php console tests:run-ui --persist-fixture-data --assume-artifacts ' . $arguments);
} else { } else {
$this->ssh->exec('php console tests:run --options="--colors" --testsuite="unit"'); $this->ssh->exec('php console tests:run --options="--colors" --testsuite="unit" ' . $arguments);
$this->ssh->exec('php console tests:run --options="--colors" --testsuite="' . $testSuite . '"'); $this->ssh->exec('php console tests:run --options="--colors" --testsuite="' . $testSuite . '" ' . $arguments);
} }
if ('system' === $testSuite) { if ('system' === $testSuite) {
......
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