Skip to content

Commit f6b64c8

Browse files
authored
Merge pull request #338 from netresearch/develop
Return exit codes of process started by 'run:test', 'run:group' or 'run:failed' command
2 parents 4317cc7 + ea5c197 commit f6b64c8

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ protected function configure()
4646
*
4747
* @param InputInterface $input
4848
* @param OutputInterface $output
49-
* @return integer|null|void
49+
* @return integer
5050
* @throws \Exception
5151
*
5252
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
5353
*/
54-
protected function execute(InputInterface $input, OutputInterface $output)
54+
protected function execute(InputInterface $input, OutputInterface $output): int
5555
{
5656
$tests = $input->getArgument('name');
5757
$skipGeneration = $input->getOption('skip-generate');
@@ -85,7 +85,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
8585
$process->setWorkingDirectory(TESTS_BP);
8686
$process->setIdleTimeout(600);
8787
$process->setTimeout(0);
88-
$process->run(
88+
89+
return $process->run(
8990
function ($type, $buffer) use ($output) {
9091
$output->write($buffer);
9192
}

src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ protected function configure()
5959
*
6060
* @param InputInterface $input
6161
* @param OutputInterface $output
62-
* @return integer|null|void
62+
* @return integer
6363
* @throws \Exception
6464
*
6565
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
6666
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6767
*/
68-
protected function execute(InputInterface $input, OutputInterface $output)
68+
protected function execute(InputInterface $input, OutputInterface $output): int
6969
{
7070
// Create Mftf Configuration
7171
MftfApplicationConfig::create(
@@ -78,7 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7878
$testConfiguration = $this->getFailedTestList();
7979

8080
if ($testConfiguration === null) {
81-
return null;
81+
// no failed tests found, run is a success
82+
return 0;
8283
}
8384

8485
$command = $this->getApplication()->find('generate:tests');
@@ -87,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8788
$command->run(new ArrayInput($args), $output);
8889

8990
$testManifestList = $this->readTestManifestFile();
90-
91+
$returnCode = 0;
9192
foreach ($testManifestList as $testCommand) {
9293
$codeceptionCommand = realpath(PROJECT_ROOT . '/vendor/bin/codecept') . ' run functional ';
9394
$codeceptionCommand .= $testCommand;
@@ -96,11 +97,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
9697
$process->setWorkingDirectory(TESTS_BP);
9798
$process->setIdleTimeout(600);
9899
$process->setTimeout(0);
99-
$process->run(
100+
$returnCode = max($returnCode, $process->run(
100101
function ($type, $buffer) use ($output) {
101102
$output->write($buffer);
102103
}
103-
);
104+
));
104105
if (file_exists(self::TESTS_FAILED_FILE)) {
105106
$this->failedList = array_merge(
106107
$this->failedList,
@@ -111,6 +112,8 @@ function ($type, $buffer) use ($output) {
111112
foreach ($this->failedList as $test) {
112113
$this->writeFailedTestToFile($test, self::TESTS_FAILED_FILE);
113114
}
115+
116+
return $returnCode;
114117
}
115118

116119
/**

src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ protected function configure()
5353
*
5454
* @param InputInterface $input
5555
* @param OutputInterface $output
56-
* @return integer|null|void
56+
* @return integer
5757
* @throws \Exception
5858
*
5959
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
6060
*/
61-
protected function execute(InputInterface $input, OutputInterface $output)
61+
protected function execute(InputInterface $input, OutputInterface $output): int
6262
{
6363
$skipGeneration = $input->getOption('skip-generate');
6464
$force = $input->getOption('force');
@@ -102,7 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
102102
$process->setWorkingDirectory(TESTS_BP);
103103
$process->setIdleTimeout(600);
104104
$process->setTimeout(0);
105-
$process->run(
105+
106+
return $process->run(
106107
function ($type, $buffer) use ($output) {
107108
$output->write($buffer);
108109
}

0 commit comments

Comments
 (0)