From 598dcf3c57b6ff914cb6b8c13d84863c525b816f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Sat, 22 Sep 2012 03:03:15 +0200 Subject: [PATCH 1/3] [Process][Tests] Prove process fail --- .../Component/Process/Tests/AbstractProcessTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 5e482a41e89e9..e2fd3c8a2e753 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -76,6 +76,17 @@ public function testProcessPipes($expected, $code) $this->assertSame($expected, $p->getErrorOutput()); } + public function testProcessOutput() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('Does it work on windows ?'); + } + + $process = $this->getProcess("echo -n 1 ; echo -n 1"); + $process->run(); + $this->assertEquals('11', $process->getOutput()); + } + public function testCallbackIsExecutedForOutput() { $p = $this->getProcess(sprintf('php -r %s', escapeshellarg('echo \'foo\';'))); From 7a955c0e4b4effa72bdcf8b1950683722b4e4acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 25 Sep 2012 10:21:47 +0200 Subject: [PATCH 2/3] [Process][Tests] Prove process fail (Add more test case) --- .../Process/Tests/AbstractProcessTest.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index e2fd3c8a2e753..a3df4e682e340 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -76,15 +76,27 @@ public function testProcessPipes($expected, $code) $this->assertSame($expected, $p->getErrorOutput()); } - public function testProcessOutput() + public function chainedCommandsOutputProvider() + { + return array( + array('11', ';', '1'), + array('22', '&&', '2'), + ); + } + + /** + * + * @dataProvider chainedCommandsOutputProvider + */ + public function testChainedCommandsOutput($expected, $operator, $input) { if (defined('PHP_WINDOWS_VERSION_BUILD')) { $this->markTestSkipped('Does it work on windows ?'); } - $process = $this->getProcess("echo -n 1 ; echo -n 1"); + $process = $this->getProcess(sprintf('echo -n %s %s echo -n %s', $input, $operator, $input)); $process->run(); - $this->assertEquals('11', $process->getOutput()); + $this->assertEquals($expected, $process->getOutput()); } public function testCallbackIsExecutedForOutput() From 27b2df9db6c978431bc00f76e63b2770bea1a9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 25 Sep 2012 15:37:18 +0200 Subject: [PATCH 3/3] [Process] Fixed bug introduced by 7bafc69f38a3512eb15aad506959a4e7be162e52. --- src/Symfony/Component/Process/Process.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index c11d5c53e0437..b40aff4a9d6e1 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -229,8 +229,6 @@ public function start($callback = null) $descriptors = array_merge($descriptors, array(array('pipe', 'w'))); $this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code'; - } else { - $this->commandline = 'exec ' . $this->commandline; } }