Merge branch '2.3' into 2.7
* 2.3: [appveyor] Fix command line [Yaml] Fix improper comments removal inside strings
This commit is contained in:
commit
9b0fa548c1
19
phpunit
19
phpunit
@ -1,7 +1,10 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Process\ProcessUtils;
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
|
require __DIR__.'/src/Symfony/Component/Process/ProcessUtils.php';
|
||||||
|
|
||||||
$PHPUNIT_VERSION = '4.8';
|
$PHPUNIT_VERSION = '4.8';
|
||||||
$PHPUNIT_DIR = __DIR__.'/.phpunit';
|
$PHPUNIT_DIR = __DIR__.'/.phpunit';
|
||||||
@ -32,7 +35,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
|
|||||||
chdir($oldPwd);
|
chdir($oldPwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cmd = array_map('escapeshellarg', $argv);
|
$cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv);
|
||||||
$exit = 0;
|
$exit = 0;
|
||||||
|
|
||||||
if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
||||||
@ -51,11 +54,13 @@ if ($phpIniMatrix) {
|
|||||||
|
|
||||||
$phpDir = dirname(`where.exe php`);
|
$phpDir = dirname(`where.exe php`);
|
||||||
|
|
||||||
$newCmd = '(SET X=0';
|
$newCmd = 'cmd /v:on /d /c "(SET X=0';
|
||||||
foreach ($phpIniMatrix as $iniFile) {
|
foreach ($phpIniMatrix as $iniFile) {
|
||||||
$newCmd .= " & copy /Y $phpDir\\$iniFile $phpDir\\php.ini & echo. & echo Running tests with $iniFile: & $cmd & (if %%errorlevel%% NEQ 0 SET X=1)";
|
$newCmd .= " & copy /Y $phpDir\\$iniFile $phpDir\\php.ini & echo. & echo Running tests with $iniFile: & ($cmd || SET X=1)";
|
||||||
}
|
}
|
||||||
$cmd = $newCmd .= ' & exit %%X%%)';
|
$cmd = $newCmd .= ' & exit !X!)%2$s"';
|
||||||
|
} else {
|
||||||
|
$cmd .= ' %2$s';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
||||||
@ -73,9 +78,9 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
|||||||
|
|
||||||
// Run phpunit tests in parallel
|
// Run phpunit tests in parallel
|
||||||
|
|
||||||
$c = escapeshellarg($component);
|
$c = ProcessUtils::escapeArgument($component);
|
||||||
|
|
||||||
if ($proc = proc_open(sprintf($cmd, $c)." > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
|
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
|
||||||
$runningProcs[$component] = $proc;
|
$runningProcs[$component] = $proc;
|
||||||
} else {
|
} else {
|
||||||
$exit = 1;
|
$exit = 1;
|
||||||
@ -137,7 +142,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
|
|||||||
// Run regular phpunit in a subprocess
|
// Run regular phpunit in a subprocess
|
||||||
|
|
||||||
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
|
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
|
||||||
if ($proc = proc_open(sprintf($cmd, '').' 2> '.escapeshellarg($errFile), array(1 => array('pipe', 'w')), $pipes)) {
|
if ($proc = proc_open(sprintf($cmd, '', ' 2> '.ProcessUtils::escapeArgument($errFile)), array(1 => array('pipe', 'w')), $pipes)) {
|
||||||
stream_copy_to_stream($pipes[1], STDOUT);
|
stream_copy_to_stream($pipes[1], STDOUT);
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
$exit = proc_close($proc);
|
$exit = proc_close($proc);
|
||||||
|
@ -375,17 +375,9 @@ class Parser
|
|||||||
|
|
||||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
||||||
|
|
||||||
// Comments must not be removed inside a block scalar
|
|
||||||
$removeCommentsPattern = '~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~';
|
|
||||||
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
|
|
||||||
|
|
||||||
while ($this->moveToNextLine()) {
|
while ($this->moveToNextLine()) {
|
||||||
$indent = $this->getCurrentLineIndentation();
|
$indent = $this->getCurrentLineIndentation();
|
||||||
|
|
||||||
if ($indent === $newIndent) {
|
|
||||||
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) {
|
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) {
|
||||||
$this->moveToPreviousLine();
|
$this->moveToPreviousLine();
|
||||||
break;
|
break;
|
||||||
@ -396,10 +388,6 @@ class Parser
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($removeComments && $this->isCurrentLineComment()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($indent >= $newIndent) {
|
if ($indent >= $newIndent) {
|
||||||
$data[] = substr($this->currentLine, $newIndent);
|
$data[] = substr($this->currentLine, $newIndent);
|
||||||
} elseif (0 == $indent) {
|
} elseif (0 == $indent) {
|
||||||
|
@ -679,6 +679,43 @@ EOF
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSecondLevelFoldedStringBlockWithComments()
|
||||||
|
{
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'pages' => array(
|
||||||
|
array(
|
||||||
|
'title' => 'some title',
|
||||||
|
'content' => <<<EOT
|
||||||
|
# comment 1
|
||||||
|
header
|
||||||
|
|
||||||
|
# comment 2
|
||||||
|
<body>
|
||||||
|
<h1>title</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
footer # comment3
|
||||||
|
EOT
|
||||||
|
),
|
||||||
|
),
|
||||||
|
), Yaml::parse(<<<EOF
|
||||||
|
pages:
|
||||||
|
-
|
||||||
|
title: some title
|
||||||
|
content: |
|
||||||
|
# comment 1
|
||||||
|
header
|
||||||
|
|
||||||
|
# comment 2
|
||||||
|
<body>
|
||||||
|
<h1>title</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
footer # comment3
|
||||||
|
EOF
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function testNestedFoldedStringBlockWithComments()
|
public function testNestedFoldedStringBlockWithComments()
|
||||||
{
|
{
|
||||||
$this->assertEquals(array(array(
|
$this->assertEquals(array(array(
|
||||||
|
Reference in New Issue
Block a user