From d4581b44e1ec3f5bdcae921d367d3e13d59e99cb Mon Sep 17 00:00:00 2001 From: Paul Siedler Date: Wed, 24 Apr 2019 16:30:32 +0200 Subject: [PATCH 1/2] #337: return the exit codes of the processes run within the command --- .../Console/RunTestCommand.php | 7 ++++--- .../Console/RunTestFailedCommand.php | 12 +++++++----- .../Console/RunTestGroupCommand.php | 7 ++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index 097d7dfd8..10e01b08a 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -46,12 +46,12 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return integer|null|void + * @return int * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $tests = $input->getArgument('name'); $skipGeneration = $input->getOption('skip-generate'); @@ -85,7 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); - $process->run( + + return $process->run( function ($type, $buffer) use ($output) { $output->write($buffer); } diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php index 13f6b8ade..f31b916d7 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php @@ -59,13 +59,13 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return integer|null|void + * @return int * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { // Create Mftf Configuration MftfApplicationConfig::create( @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $command->run(new ArrayInput($args), $output); $testManifestList = $this->readTestManifestFile(); - + $returnCode = 0; foreach ($testManifestList as $testCommand) { $codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional '; $codeceptionCommand .= $testCommand; @@ -96,11 +96,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); - $process->run( + $returnCode = max($returnCode, $process->run( function ($type, $buffer) use ($output) { $output->write($buffer); } - ); + )); if (file_exists(self::TESTS_FAILED_FILE)) { $this->failedList = array_merge( $this->failedList, @@ -111,6 +111,8 @@ function ($type, $buffer) use ($output) { foreach ($this->failedList as $test) { $this->writeFailedTestToFile($test, self::TESTS_FAILED_FILE); } + + return $returnCode; } /** diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 3098569fb..507f46368 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -53,12 +53,12 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return integer|null|void + * @return int * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $skipGeneration = $input->getOption('skip-generate'); $force = $input->getOption('force'); @@ -102,7 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $process->setWorkingDirectory(TESTS_BP); $process->setIdleTimeout(600); $process->setTimeout(0); - $process->run( + + return $process->run( function ($type, $buffer) use ($output) { $output->write($buffer); } From d7ea51dcd50e3ef78e7467ca37d4d937e06d6cde Mon Sep 17 00:00:00 2001 From: Paul Siedler Date: Wed, 24 Apr 2019 17:00:45 +0200 Subject: [PATCH 2/2] #337: adjust type annotations, ensoure integer return type in all instances --- .../FunctionalTestingFramework/Console/RunTestCommand.php | 2 +- .../Console/RunTestFailedCommand.php | 5 +++-- .../Console/RunTestGroupCommand.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php index 10e01b08a..33a29b2e8 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php @@ -46,7 +46,7 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return int + * @return integer * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php index f31b916d7..8257162b9 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php @@ -59,7 +59,7 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return int + * @return integer * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable) @@ -78,7 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $testConfiguration = $this->getFailedTestList(); if ($testConfiguration === null) { - return null; + // no failed tests found, run is a success + return 0; } $command = $this->getApplication()->find('generate:tests'); diff --git a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php index 507f46368..e895fb66a 100644 --- a/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php +++ b/src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php @@ -53,7 +53,7 @@ protected function configure() * * @param InputInterface $input * @param OutputInterface $output - * @return int + * @return integer * @throws \Exception * * @SuppressWarnings(PHPMD.UnusedLocalVariable)