Merge "Fix some issues with Microsoft SQL Server support"
[lhc/web/wiklou.git] / tests / phpunit / phpunit.php
index 1aa2b4d..2b77752 100755 (executable)
@@ -6,7 +6,8 @@
  * @file
  */
 
-// Set a flag which can be used to detect when other scripts have been entered through this entry point or not
+// Set a flag which can be used to detect when other scripts have been entered
+// through this entry point or not.
 define( 'MW_PHPUNIT_TEST', true );
 
 // Start up MediaWiki in command-line mode
@@ -16,8 +17,10 @@ class PHPUnitMaintClass extends Maintenance {
 
        public function __construct() {
                parent::__construct();
-               $this->addOption( 'with-phpunitdir',
-                       'Directory to include PHPUnit from, for example when using a git fetchout from upstream. Path will be prepended to PHP `include_path`.',
+               $this->addOption(
+                       'with-phpunitdir',
+                       'Directory to include PHPUnit from, for example when using a git '
+                               . 'fetchout from upstream. Path will be prepended to PHP `include_path`.',
                        false, # not required
                        true # need arg
                );
@@ -114,4 +117,15 @@ if ( PHPUnit_Runner_Version::id() !== '@package_version@'
 if ( !class_exists( 'PHPUnit_TextUI_Command' ) ) {
        require_once 'PHPUnit/Autoload.php';
 }
+
+// Prevent segfault when we have lots of unit tests (bug 62623)
+if ( version_compare( PHP_VERSION, '5.4.0', '<' )
+       && version_compare( PHP_VERSION, '5.3.0', '>=' )
+) {
+       register_shutdown_function( function() {
+               gc_collect_cycles();
+               gc_disable();
+       } );
+}
+
 MediaWikiPHPUnitCommand::main();