Skip to content

Commit

Permalink
Merge pull request #338 from netresearch/develop
Browse files Browse the repository at this point in the history
Return exit codes of process started by 'run:test', 'run:group' or 'run:failed' command
  • Loading branch information
KevinBKozan authored Apr 24, 2019
2 parents 4317cc7 + ea5c197 commit f6b64c8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ protected function configure()
*
* @param InputInterface $input
* @param OutputInterface $output
* @return integer|null|void
* @return integer
* @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');
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ protected function configure()
*
* @param InputInterface $input
* @param OutputInterface $output
* @return integer|null|void
* @return integer
* @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(
Expand All @@ -78,7 +78,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$testConfiguration = $this->getFailedTestList();

if ($testConfiguration === null) {
return null;
// no failed tests found, run is a success
return 0;
}

$command = $this->getApplication()->find('generate:tests');
Expand All @@ -87,7 +88,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;
Expand All @@ -96,11 +97,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,
Expand All @@ -111,6 +112,8 @@ function ($type, $buffer) use ($output) {
foreach ($this->failedList as $test) {
$this->writeFailedTestToFile($test, self::TESTS_FAILED_FILE);
}

return $returnCode;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ protected function configure()
*
* @param InputInterface $input
* @param OutputInterface $output
* @return integer|null|void
* @return integer
* @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');
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f6b64c8

Please sign in to comment.