X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fphpunit.php;h=2b77752c4bcd95488e457ec65c25dad19ebdb0e0;hb=13e33c28983461d5b8bdc1dece0cd0a35347a261;hp=039cabbd7f463fac4721bf5beb35f6820f1fb603;hpb=ea484007509b0caa7190a8683d8ea78d8fdf97e4;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php index 039cabbd7f..2b77752c4b 100755 --- a/tests/phpunit/phpunit.php +++ b/tests/phpunit/phpunit.php @@ -6,9 +6,8 @@ * @file */ -/* Configuration */ - -// 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,10 +15,12 @@ require_once dirname( dirname( __DIR__ ) ) . "/maintenance/Maintenance.php"; class PHPUnitMaintClass extends Maintenance { - function __construct() { + 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 ); @@ -72,7 +73,8 @@ class PHPUnitMaintClass extends Maintenance { } # --with-phpunitdir let us override the default PHPUnit version - if ( $phpunitDir = $this->getOption( 'with-phpunitdir' ) ) { + if ( $this->hasOption( 'with-phpunitdir' ) ) { + $phpunitDir = $this->getOption( 'with-phpunitdir' ); # Sanity checks if ( !is_dir( $phpunitDir ) ) { $this->error( "--with-phpunitdir should be set to an existing directory", 1 ); @@ -83,8 +85,7 @@ class PHPUnitMaintClass extends Maintenance { # Now prepends provided PHPUnit directory $this->output( "Will attempt loading PHPUnit from `$phpunitDir`\n" ); - set_include_path( $phpunitDir - . PATH_SEPARATOR . get_include_path() ); + set_include_path( $phpunitDir . PATH_SEPARATOR . get_include_path() ); # Cleanup $args array so the option and its value do not # pollute PHPUnit @@ -116,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();