Skip to content

Commit

Permalink
Disable Process timeout (unlimited runtime)
Browse files Browse the repository at this point in the history
and remove the --timeout option from the shell:exec command.
  • Loading branch information
boite committed Sep 29, 2016
1 parent eaac7c5 commit 8093f6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
13 changes: 2 additions & 11 deletions src/Command/ShellExecCommand.php
Expand Up @@ -4,7 +4,6 @@

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -29,13 +28,6 @@ public function configure()
InputArgument::REQUIRED,
'The command and arguments to be executed by the shell.'
)
->addOption(
'timeout',
't',
InputOption::VALUE_REQUIRED,
'The maximum permitted execution time in seconds.',
60
)
;
}

Expand All @@ -46,8 +38,7 @@ public function execute(InputInterface $input, OutputInterface $output)
'bash',
'-c',
$input->getArgument('command-line')
),
$input->getOption('timeout')
)
);

if ($p->run()) {
Expand All @@ -67,7 +58,7 @@ public function execute(InputInterface $input, OutputInterface $output)
/**
* @return \Symfony\Component\Process\Process
*/
private function getProcess($arguments, $timeout)
private function getProcess($arguments, $timeout = 0.0)
{
return $this
->processBuilder
Expand Down
16 changes: 15 additions & 1 deletion test/Droid/Command/ShellExecCommandTest.php
Expand Up @@ -26,7 +26,7 @@ protected function setUp()
;
$this->processBuilder = $this
->getMockBuilder(ProcessBuilder::class)
->setMethods(array('setArguments', 'getProcess'))
->setMethods(array('setArguments', 'setTimeout', 'getProcess'))
->getMock()
;

Expand All @@ -47,6 +47,13 @@ public function testCommandWillFail()
->with(array('bash', '-c', 'echo "Hello world"'))
->willReturnSelf()
;
$this
->processBuilder
->expects($this->once())
->method('setTimeout')
->with($this->equalTo(0.0))
->willReturnSelf()
;
$this
->processBuilder
->expects($this->once())
Expand Down Expand Up @@ -94,6 +101,13 @@ public function testCommandWillSucceed()
->with(array('bash', '-c', 'echo "Hello world"'))
->willReturnSelf()
;
$this
->processBuilder
->expects($this->once())
->method('setTimeout')
->with($this->equalTo(0.0))
->willReturnSelf()
;
$this
->processBuilder
->expects($this->once())
Expand Down

0 comments on commit 8093f6f

Please sign in to comment.