File: 0005-Process-Make-test-AbstractProcessTest-testStartAfter.patch

package info (click to toggle)
symfony 2.3.21%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 31,028 kB
  • sloc: php: 162,090; xml: 2,839; sh: 422; sql: 246; makefile: 78
file content (45 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download | duplicates (2)
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);