Navigation Menu

Skip to content

Commit

Permalink
bug #11381 [2.3] [Process] Use correct test for empty string in UnixP…
Browse files Browse the repository at this point in the history
…ipes (whs, romainneutron)

This PR was merged into the 2.3 branch.

Discussion
----------

[2.3] [Process] Use correct test for empty string in UnixPipes

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

This PR supersedes #11264 : 2.3 compatibility + Windows compatibility + CS fix

Commits
-------

cec0a45 [Process] Adjust PR #11264, make it Windows compatible and fix CS
9e1ea4a [Process] Use correct test for empty string in UnixPipes
  • Loading branch information
fabpot committed Jul 16, 2014
2 parents 45df2f3 + cec0a45 commit 91e32f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Process/ProcessPipes.php
Expand Up @@ -313,11 +313,11 @@ private function readStreams($blocking, $close = false)
$type = array_search($pipe, $this->pipes);

$data = '';
while ($dataread = fread($pipe, self::CHUNK_SIZE)) {
while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) {
$data .= $dataread;
}

if ($data) {
if ('' !== $data) {
$read[$type] = $data;
}

Expand Down
13 changes: 13 additions & 0 deletions src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Expand Up @@ -287,6 +287,19 @@ public function testGetIncrementalOutput()
}
}

public function testZeroAsOutput()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
// see http://stackoverflow.com/questions/7105433/windows-batch-echo-without-new-line
$p = $this->getProcess('echo | set /p dummyName=0');
} else {
$p = $this->getProcess('printf 0');
}

$p->run();
$this->assertSame('0', $p->getOutput());
}

public function testExitCodeCommandFailed()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
Expand Down

0 comments on commit 91e32f8

Please sign in to comment.