8000 Merge branch '2.3' into 2.7 · symfony/symfony@f80e6c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f80e6c6

Browse files
committed
Merge branch '2.3' into 2.7
* 2.3: [DependencyInjection] improved a comment for reading fluency [HttpKernel] change a class in tests to avoid depending on SQLite [ci] Display fastest results first when running tests in parallel [Yaml] Improve newline handling in folded scalar blocks
2 parents 899c212 + 5e46485 commit f80e6c6

File tree

7 files changed

+91
-63
lines changed

7 files changed

+91
-63
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ install:
4646
- if [ "$deps" != "no" ]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
4747

4848
script:
49-
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
49+
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
5050
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
51-
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
52-
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
51+
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
52+
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;

phpunit

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ $exit = 0;
3333
if (isset($argv[1]) && 'symfony' === $argv[1]) {
3434
// Find Symfony components in plain php for Windows portability
3535

36-
$finder = new RecursiveDirectoryIterator('src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
36+
$finder = new RecursiveDirectoryIterator(__DIR__.'/src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
3737
$finder = new RecursiveIteratorIterator($finder);
3838
$finder->setMaxDepth(3);
3939

4040
array_shift($cmd);
4141
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
42-
$procs = array();
42+
$runningProcs = array();
4343

4444
foreach ($finder as $file => $fileInfo) {
4545
if ('phpunit.xml.dist' === $file) {
@@ -50,7 +50,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
5050
$c = escapeshellarg($component);
5151

5252
if ($proc = proc_open(implode(' ', $cmd)." $c > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
53-
$procs[$component] = $proc;
53+
$runningProcs[$component] = $proc;
5454
} else {
5555
$exit = 1;
5656
echo "\033[41mKO\033[0m $component\n\n";
@@ -59,44 +59,54 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
5959
}
6060

6161
// Fixes for colors support on appveyor
62-
// See http://help.appveyor.com/discussions/suggestions/197-support-ansi-color-codes
62+
// See https://github.com/appveyor/ci/issues/373
6363
$colorFixes = array(
6464
array("S\033[0m\033[0m\033[36m\033[1mS", "E\033[0m\033[0m\033[31m\033[1mE", "I\033[0m\033[0m\033[33m\033[1mI", "F\033[0m\033[0m\033[41m\033[37mF"),
6565
array("SS", "EE", "II", "FF"),
6666
);
6767
$colorFixes[0] = array_merge($colorFixes[0], $colorFixes[0]);
6868
$colorFixes[1] = array_merge($colorFixes[1], $colorFixes[1]);
6969

70-
foreach ($procs as $component => $proc) {
71-
$procStatus = proc_close($proc);
72-
73-
foreach (array('out', 'err') as $file) {
74-
$file = "$component/phpunit.std$file";
70+
while ($runningProcs) {
71+
usleep(300000);
72+
$terminatedProcs = array();
73+
foreach ($runningProcs as $component => $proc) {
74+
$procStatus = proc_get_status($proc);
75+
if (!$procStatus['running']) {
76+
$terminatedProcs[$component] = $procStatus['exitcode'];
77+
unset($runningProcs[$component]);
78+
proc_close($proc);
79+
}
80+
}
7581

76-
if ('\\' === DIRECTORY_SEPARATOR) {
77-
$h = fopen($file, 'rb');
78-
while (false !== $line = fgets($h)) {
79-
echo str_replace($colorFixes[0], $colorFixes[1], preg_replace(
80-
'/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/',
81-
"$1m\033[$2$3$4$4",
82-
$line
83-
));
82+
foreach ($terminatedProcs as $component => $procStatus) {
83+
foreach (array('out', 'err') as $file) {
84+
$file = "$component/phpunit.std$file";
85+
86+
if ('\\' === DIRECTORY_SEPARATOR) {
87+
$h = fopen($file, 'rb');
88+
while (false !== $line = fgets($h)) {
89+
echo str_replace($colorFixes[0], $colorFixes[1], preg_replace(
90+
'/(\033\[[0-9]++);([0-9]++m)(?:(.)(\033\[0m))?/',
91+
"$1m\033[$2$3$4$4",
92+
$line
93+
));
94+
}
95+
fclose($h);
96+
} else {
97+
readfile($file);
8498
}
85-
fclose($h);
86-
} else {
87-
readfile($file);
99+
unlink($file);
88100
}
89-
unlink($file);
90-
}
91101

92-
if ($procStatus) {
93-
$exit = 1;
94-
echo "\033[41mKO\033[0m $component\n\n";
95-
} else {
96-
echo "\033[32mOK\033[0m $component\n\n";
102+
if ($procStatus) {
103+
$exit = 1;
104+
echo "\033[41mKO\033[0m $component\n\n";
105+
} else {
106+
echo "\033[32mOK\033[0m $component\n\n";
107+
}
97108
}
98109
}
99-
100110
} elseif (!isset($argv[1]) || 'install' !== $argv[1]) {
101111
// Run regular phpunit in a subprocess
102112

src/Symfony/Component/Finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RecursiveDirectoryIteratorTest extends IteratorTestCase
2121
public function testRewindOnFtp()
2222
{
2323
try {
24-
$i = new RecursiveDirectoryIterator('ftp://ftp.mozilla.org/', \RecursiveDirectoryIterator::SKIP_DOTS);
24+
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
2525
} catch (\UnexpectedValueException $e) {
2626
$this->markTestSkipped('Unsupported stream "ftp".');
2727
}
@@ -37,14 +37,14 @@ public function testRewindOnFtp()
3737
public function testSeekOnFtp()
3838
{
3939
try {
40-
$i = new RecursiveDirectoryIterator('ftp://ftp.mozilla.org/', \RecursiveDirectoryIterator::SKIP_DOTS);
40+
$i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
4141
} catch (\UnexpectedValueException $e) {
4242
$this->markTestSkipped('Unsupported stream "ftp".');
4343
}
4444

4545
$contains = array(
46-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'README',
47-
'ftp://ftp.mozilla.org'.DIRECTORY_SEPARATOR.'pub',
46+
'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'1000GB.zip',
47+
'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'100GB.zip',
4848
);
4949
$actual = array();
5050

src/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
* This extension sub-class provides first-class integration with the
1818
* Config/Definition Component.
1919
*
20-
* You can use this as base class if you
20+
* You can use this as base class if
2121
*
22-
* a) use the Config/Definition component for configuration
23-
* b) your configuration class is named "Configuration" and
24-
* c) the configuration class resides in the DependencyInjection sub-folder
22+
* a) you use the Config/Definition component for configuration,
23+
* b) your configuration class is named "Configuration", and
24+
* c) the configuration class resides in the DependencyInjection sub-folder.
2525
*
2626
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2727
*/

src/Symfony/Component/HttpKernel/Tests/Profiler/ProfilerTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\HttpKernel\Tests\Profiler;
1313

1414
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
15-
use Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage;
15+
use Symfony\Component\HttpKernel\Profiler\FileProfilerStorage;
1616
use Symfony\Component\HttpKernel\Profiler\Profiler;
1717
use Symfony\Component\HttpFoundation\Request;
1818
use Symfony\Component\HttpFoundation\Response;
@@ -61,16 +61,12 @@ public function testFindWorksWithInvalidDates()
6161

6262
protected function setUp()
6363
{
64-
if (!class_exists('SQLite3') && (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers()))) {
65-
$this->markTestSkipped('This test requires SQLite support in your environment');
66-
}
67-
6864
$this->tmp = tempnam(sys_get_temp_dir(), 'sf2_profiler');
6965
if (file_exists($this->tmp)) {
7066
@unlink($this->tmp);
7167
}
7268

73-
$this->storage = new SqliteProfilerStorage('sqlite:'.$this->tmp);
69+
$this->storage = new FileProfilerStorage('file:'.$this->tmp);
7470
$this->storage->purge();
7571
}
7672

src/Symfony/Component/Yaml/Parser.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
*/
2121
class Parser
2222
{
23-
const FOLDED_SCALAR_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
23+
const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
24+
// BC - wrongly named
25+
const FOLDED_SCALAR_PATTERN = self::BLOCK_SCALAR_HEADER_PATTERN;
2426

2527
private $offset = 0;
2628
private $lines = array();
@@ -373,8 +375,8 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
373375

374376
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
375377

376-
// Comments must not be removed inside a string block (ie. after a line ending with "|")
377-
$removeCommentsPattern = '~'.self::FOLDED_SCALAR_PATTERN.'$~';
378+
// Comments must not be removed inside a block scalar
379+
$removeCommentsPattern = '~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~';
378380
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
379381

380382
while ($this->moveToNextLine()) {
@@ -464,10 +466,10 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $ob
464466
return $this->refs[$value];
465467
}
466468

467-
if (preg_match('/^'.self::FOLDED_SCALAR_PATTERN.'$/', $value, $matches)) {
469+
if (preg_match('/^'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
468470
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
469471

470-
return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
472+
return $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
471473
}
472474

473475
try {
@@ -481,15 +483,15 @@ private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $ob
481483
}
482484

483485
/**
484-
* Parses a folded scalar.
486+
* Parses a block scalar.
485487
*
486-
* @param string $separator The separator that was used to begin this folded scalar (| or >)
487-
* @param string $indicator The indicator that was used to begin this folded scalar (+ or -)
488-
* @param int $indentation The indentation that was used to begin this folded scalar
488+
* @param string $style The style indicator that was used to begin this block scalar (| or >)
489+
* @param string $chomping The chomping indicator that was used to begin this block scalar (+ or -)
490+
* @param int $indentation The indentation indicator that was used to begin this block scalar
489491
*
490492
* @return string The text value
491493
*/
492-
private function parseFoldedScalar($separator, $indicator = '', $indentation = 0)
494+
private function parseBlockScalar($style, $chomping = '', $indentation = 0)
493495
{
494496
$notEOF = $this->moveToNextLine();
495497
if (!$notEOF) {
@@ -544,17 +546,23 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0
544546
$this->moveToPreviousLine();
545547
}
546548

547-
// replace all non-trailing single newlines with spaces in folded blocks
548-
if ('>' === $separator) {
549+
// folded style
550+
if ('>' === $style) {
551+
// folded lines
552+
// replace all non-leading/non-trailing single newlines with spaces
549553
preg_match('/(\n*)$/', $text, $matches);
550-
$text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n"));
554+
$text = preg_replace('/(?<!\n|^)\n(?!\n)/', ' ', rtrim($text, "\n"));
551555
$text .= $matches[1];
556+
557+
// empty separation lines
558+
// remove one newline from each group of non-leading/non-trailing newlines
559+
$text = preg_replace('/[^\n]\n+\K\n(?=[^\n])/', '', $text);
552560
}
553561

554-
// deal with trailing newlines as indicated
555-
if ('' === $indicator) {
562+
// deal with trailing newlines
563+
if ('' === $chomping) {
556564
$text = preg_replace('/\n+$/', "\n", $text);
557-
} elseif ('-' === $indicator) {
565+
} elseif ('-' === $chomping) {
558566
$text = preg_replace('/\n+$/', '', $text);
559567
}
560568

src/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ php: |
5151
'~',
5252
)
5353
---
54-
test: Empty lines in folded blocks
54+
test: Empty lines in literal blocks
5555
brief: >
56-
Empty lines in folded blocks
56+
Empty lines in literal blocks
5757
yaml: |
5858
foo:
5959
bar: |
@@ -65,6 +65,20 @@ yaml: |
6565
php: |
6666
array('foo' => array('bar' => "foo\n\n\n \nbar\n"))
6767
---
68+
test: Empty lines in folded blocks
69+
brief: >
70+
Empty lines in folded blocks
71+
yaml: |
72+
foo:
73+
bar: >
74+
75+
foo
76+
77+
78+
bar
79+
php: |
80+
array('foo' => array('bar' => "\nfoo\n\nbar\n"))
81+
---
6882
test: IP addresses
6983
brief: >
7084
IP addresses

0 commit comments

Comments
 (0)
0