Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ba3afdb

Browse files
Merge branch '2.8'
* 2.8: [ci] Force update of ./phpunit deps [PhpUnitBridge] fix typo [Bridge\PhpUnit] Display the stack trace of a deprecation on-demand [Form] Fixed: Duplicate choice labels are remembered when using "choices_as_values" = false [Process] Don't catch RuntimeException when it complicates tests debugging [appveyor] Workaround transient segfault when APCu is enabled Conflicts: appveyor.yml src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
2 parents 743e670 + d94c322 commit ba3afdb

File tree

7 files changed

+63
-41
lines changed

7 files changed

+63
-41
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ before_install:
3838
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi;
3939
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> $INI_FILE; fi;
4040
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = memcache.so" >> $INI_FILE; fi;
41-
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.7 && echo "apc.enable_cli = 1" >> $INI_FILE) || echo "Let's continue without apcu extension"; fi;
41+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.8 && echo "apc.enable_cli = 1" >> $INI_FILE) || echo "Let's continue without apcu extension"; fi;
4242
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then pecl install -f memcached-2.1.0 || echo "Let's continue without memcached extension"; fi;
4343
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]] && [ "$deps" = "no" ]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo "extension = $(pwd)/modules/symfony_debug.so" >> $INI_FILE); fi;
4444
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "extension = ldap.so" >> $INI_FILE; fi;

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ install:
2222
- IF %PHP%==1 7z x php-5.5.9-nts-Win32-VC11-x86.zip -y >nul
2323
- IF %PHP%==1 del /Q *.zip
2424
- IF %PHP%==1 cd ext
25-
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apcu/4.0.7/php_apcu-4.0.7-5.5-nts-vc11-x86.zip
26-
- IF %PHP%==1 7z x php_apcu-4.0.7-5.5-nts-vc11-x86.zip -y >nul
25+
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apcu/4.0.8/php_apcu-4.0.8-5.5-nts-vc11-x86.zip
26+
- IF %PHP%==1 7z x php_apcu-4.0.8-5.5-nts-vc11-x86.zip -y >nul
2727
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/php_memcache-3.0.8-5.5-nts-vc11-x86.zip
2828
- IF %PHP%==1 7z x php_memcache-3.0.8-5.5-nts-vc11-x86.zip -y >nul
2929
- IF %PHP%==1 del /Q *.zip

phpunit

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
// Please update when phpunit needs to be reinstalled with fresh deps:
14-
// Cache-Id-Version: 2015-11-18 14:14 UTC
14+
// Cache-Id-Version: 2015-11-28 09:05 UTC
1515

1616
use Symfony\Component\Process\ProcessUtils;
1717

@@ -164,7 +164,8 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
164164
unlink($file);
165165
}
166166

167-
if ($procStatus) {
167+
// Fail on any individual component failures but ignore STATUS_STACK_BUFFER_OVERRUN (-1073740791) on Windows when APCu is enabled
168+
if ($procStatus && ('\\' !== DIRECTORY_SEPARATOR || !extension_loaded('apcu') || !ini_get('apc.enable_cli') || -1073740791 !== $procStatus)) {
168169
$exit = 1;
169170
echo "\033[41mKO\033[0m $component\n\n";
170171
} else {

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,37 @@ public static function register($mode = false)
4747
// No-op
4848
}
4949

50-
if (0 !== error_reporting()) {
51-
$group = 'unsilenced';
52-
$ref = &$deprecations[$group][$msg]['count'];
53-
++$ref;
54-
} elseif (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
50+
if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) {
5551
$class = isset($trace[$i]['object']) ? get_class($trace[$i]['object']) : $trace[$i]['class'];
5652
$method = $trace[$i]['function'];
5753

58-
$group = 0 === strpos($method, 'testLegacy') || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') || in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true) ? 'legacy' : 'remaining';
54+
if (0 !== error_reporting()) {
55+
$group = 'unsilenced';
56+
} elseif (0 === strpos($method, 'testLegacy')
57+
|| 0 === strpos($method, 'provideLegacy')
58+
|| 0 === strpos($method, 'getLegacy')
59+
|| strpos($class, '\Legacy')
60+
|| in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true)
61+
) {
62+
$group = 'legacy';
63+
} else {
64+
$group = 'remaining';
65+
}
66+
67+
if (isset($mode[0]) && '/' === $mode[0] && preg_match($mode, $class.'::'.$method)) {
68+
$e = new \Exception($msg);
69+
$r = new \ReflectionProperty($e, 'trace');
70+
$r->setAccessible(true);
71+
$r->setValue($e, array_slice($trace, 1, $i));
5972

73+
echo "\n".ucfirst($group).' deprecation triggered by '.$class.'::'.$method.':';
74+
echo "\n".$msg;
75+
echo "\nStack trace:";
76+
echo "\n".str_replace(' '.getcwd().DIRECTORY_SEPARATOR, ' ', $e->getTraceAsString());
77+
echo "\n";
78+
79+
exit(1);
80+
}
6081
if ('legacy' !== $group && 'weak' !== $mode) {
6182
$ref = &$deprecations[$group][$msg]['count'];
6283
++$ref;
@@ -78,7 +99,7 @@ public static function register($mode = false)
7899
restore_error_handler();
79100
self::register($mode);
80101
}
81-
} else {
102+
} elseif (!isset($mode[0]) || '/' !== $mode[0]) {
82103
self::$isRegistered = true;
83104
if (self::hasColorSupport()) {
84105
$colorize = function ($str, $red) {

src/Symfony/Bridge/PhpUnit/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ It comes with the following features:
88
* disable the garbage collector;
99
* enforce a consistent `C` locale;
1010
* auto-register `class_exists` to load Doctrine annotations;
11-
* print a user deprecation notices summary at the end of the test suite.
11+
* print a user deprecation notices summary at the end of the test suite;
12+
* display the stack trace of a deprecation on-demand.
1213

1314
By default any non-legacy-tagged or any non-@-silenced deprecation notices will
1415
make tests fail.
@@ -51,3 +52,9 @@ You have to decide either to:
5152
* update your code to not use deprecated interfaces anymore, thus gaining better
5253
forward compatibility;
5354
* or move them to the **Legacy** section (by using one of the above way).
55+
56+
In case you need to inspect the stack trace of a particular deprecation triggered by
57+
one of your unit tests, you can set the `SYMFONY_DEPRECATIONS_HELPER` env var to
58+
a regexp that matches this test case's `class::method` name. For example,
59+
`SYMFONY_DEPRECATIONS_HELPER=/^MyTest::testMethod$/ phpunit` will stop your test
60+
suite once a deprecation is triggered by the `MyTest::testMethod` test.

src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
* ```
4242
*
4343
* @author Bernhard Schussek <[email protected]>
44+
*
45+
* @deprecated since version 2.8, to be removed in 3.0. Use ArrayChoiceList instead.
4446
*/
4547
class ArrayKeyChoiceList extends ArrayChoiceList
4648
{

src/Symfony/Component/Process/Tests/SimpleProcessTest.php

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -152,46 +152,37 @@ public function testSignalWithWrongNonIntSignal()
152152

153153
public function testStopTerminatesProcessCleanly()
154154
{
155-
try {
156-
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
157-
$process->run(function () use ($process) {
158-
$process->stop();
159-
});
160-
} catch (\RuntimeException $e) {
161-
$this->fail('A call to stop() is not expected to cause wait() to throw a RuntimeException');
162-
}
155+
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
156+
$process->run(function () use ($process) {
157+
$process->stop();
158+
});
159+
$this->assertTrue(true, 'A call to stop() is not expected to cause wait() to throw a RuntimeException');
163160
}
164161

165162
public function testKillSignalTerminatesProcessCleanly()
166163
{
167164
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
168165

169-
try {
170-
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
171-
$process->run(function () use ($process) {
172-
if ($process->isRunning()) {
173-
$process->signal(defined('SIGKILL') ? SIGKILL : 9);
174-
}
175-
});
176-
} catch (\RuntimeException $e) {
177-
$this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException');
178-
}
166+
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
167+
$process->run(function () use ($process) {
168+
if ($process->isRunning()) {
169+
$process->signal(defined('SIGKILL') ? SIGKILL : 9);
170+
}
171+
});
172+
$this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
179173
}
180174

181175
public function testTermSignalTerminatesProcessCleanly()
182176
{
183177
$this->expectExceptionIfPHPSigchild('Symfony\Component\Process\Exception\RuntimeException', 'This PHP has been compiled with --enable-sigchild. The process can not be signaled.');
184178

185-
try {
186-
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
187-
$process->run(function () use ($process) {
188-
if ($process->isRunning()) {
189-
$process->signal(defined('SIGTERM') ? SIGTERM : 15);
190-
}
191-
});
192-
} catch (\RuntimeException $e) {
193-
$this->fail('A call to signal() is not expected to cause wait() to throw a RuntimeException');
194-
}
179+
$process = $this->getProcess(self::$phpBin.' -r "echo \'foo\'; sleep(1); echo \'bar\';"');
180+
$process->run(function () use ($process) {
181+
if ($process->isRunning()) {
182+
$process->signal(defined('SIGTERM') ? SIGTERM : 15);
183+
}
184+
});
185+
$this->assertTrue(true, 'A call to signal() is not expected to cause wait() to throw a RuntimeException');
195186
}
196187

197188
public function testStopWithTimeoutIsActuallyWorking()

0 commit comments

Comments
 (0)