From 8093f6f416829714e8ee9a25a8de5e84e8f6f835 Mon Sep 17 00:00:00 2001 From: boite Date: Thu, 29 Sep 2016 17:19:10 +0100 Subject: [PATCH] Disable Process timeout (unlimited runtime) and remove the --timeout option from the shell:exec command. --- src/Command/ShellExecCommand.php | 13 ++----------- test/Droid/Command/ShellExecCommandTest.php | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Command/ShellExecCommand.php b/src/Command/ShellExecCommand.php index 0431922..39dc625 100644 --- a/src/Command/ShellExecCommand.php +++ b/src/Command/ShellExecCommand.php @@ -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; @@ -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 - ) ; } @@ -46,8 +38,7 @@ public function execute(InputInterface $input, OutputInterface $output) 'bash', '-c', $input->getArgument('command-line') - ), - $input->getOption('timeout') + ) ); if ($p->run()) { @@ -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 diff --git a/test/Droid/Command/ShellExecCommandTest.php b/test/Droid/Command/ShellExecCommandTest.php index d889ce9..1a166b6 100644 --- a/test/Droid/Command/ShellExecCommandTest.php +++ b/test/Droid/Command/ShellExecCommandTest.php @@ -26,7 +26,7 @@ protected function setUp() ; $this->processBuilder = $this ->getMockBuilder(ProcessBuilder::class) - ->setMethods(array('setArguments', 'getProcess')) + ->setMethods(array('setArguments', 'setTimeout', 'getProcess')) ->getMock() ; @@ -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()) @@ -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())