1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
From: Daniel Beyer <dabe@deb.ymc.ch>
Date: Mon, 19 Jan 2015 17:51:06 +0100
Subject: [Process] Make test AbstractProcessTest::testStartAfterATimeout
useful again
The test AbstractProcessTest::testStartAfterATimeout() is pretty useless, due
to two reasons:
1. Any exception is caught
This means even the exception thrown with
$this->fail('A RuntimeException should have been raised.');
is caught, making the test pretty useless.
2. Invalid PHP code gets executed
The command that is executed in the tests actually is:
# php -r "$n = 1000; while ($n--) {echo ''; usleep(1000); }"
This does not wait ~1s, but produces the following error:
PHP Parse error: syntax error, unexpected '=' in Command line code on line 1
Forwarded: https://github.com/symfony/symfony/pull/13446
---
src/Symfony/Component/Process/Tests/AbstractProcessTest.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php
index 53ac93e..a4c04ed 100644
--- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php
+++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php
@@ -672,12 +672,12 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
public function testStartAfterATimeout()
{
- $process = $this->getProcess('php -r "$n = 1000; while ($n--) {echo \'\'; usleep(1000); }"');
+ $process = $this->getProcess(sprintf('php -r %s', escapeshellarg('$n = 1000; while ($n--) {echo \'\'; usleep(1000); }')));
$process->setTimeout(0.1);
try {
$process->run();
- $this->fail('An exception should have been raised.');
- } catch (\Exception $e) {
+ $this->fail('A RuntimeException should have been raised.');
+ } catch (RuntimeException $e) {
}
$process->start();
usleep(10000);
|