Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix atoum command exit codes #98

Merged
merged 1 commit into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# `dev-master`

## Bugfix

* [#98](https://github.com/atoum/AtoumBundle/pull/98) Fix atoum command exit codes ([@jubianchi])

1.4.0
=====

Expand Down Expand Up @@ -37,3 +43,5 @@

* Move the bundle to atoum vendor namespace
* Add ControllerTest class

[@jubianchi]: https://github.com/jubianchi
22 changes: 21 additions & 1 deletion Command/AtoumCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,27 @@ protected function execute(InputInterface $input, OutputInterface $output)
$reportCli->addWriter($writerCli);
}

$runner->run($this->getAtoumArguments());
try {
$score = $runner->run($this->getAtoumArguments())->getRunner()->getScore();

$isSuccess = $score->getFailNumber() <= 0 && $score->getErrorNumber() <= 0 && $score->getExceptionNumber() <= 0;

if ($runner->shouldFailIfVoidMethods() && $score->getVoidMethodNumber() > 0)
{
$isSuccess = false;
}

if ($runner->shouldFailIfSkippedMethods() && $score->getSkippedMethodNumber() > 0)
{
$isSuccess = false;
}

return $isSuccess ? 0 : 1;
} catch (\Exception $exception) {
$this->getApplication()->renderException($exception, $output);

return 2;
}
}

/**
Expand Down
11 changes: 5 additions & 6 deletions tests/units/Test/Units/CommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ public function testCreateCommandTester()
$this
->given(
$command = new \mock\Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand($commandName = uniqid()),
$command->getMockController()->run = $status = uniqid()
)
->given(
$kernel = new \mock\Symfony\Component\HttpKernel\KernelInterface(),
$application = new \mock\Symfony\Bundle\FrameworkBundle\Console\Application($kernel)
)
->given(
$container = new \mock\Symfony\Component\DependencyInjection\ContainerInterface(),
$application = new \mock\Symfony\Bundle\FrameworkBundle\Console\Application($kernel),
$object = new \mock\atoum\AtoumBundle\Test\Units\CommandTestCase(),
$command->getMockController()->run = $status = uniqid(),
$kernel->getMockController()->getBundles = array(),
$kernel->getMockController()->getContainer = $container,
$object->getMockController()->getKernel = $kernel
)
->if($commandTester = $object->createCommandTester($command))
Expand Down