jenkins-bot has submitted this change and it was merged.
Change subject: Improve PHPUnit detection code
......................................................................
Improve PHPUnit detection code
The code that attempts to load PHPUnit is simpler and clearer when rewritten as
a loop that iterates through a set of possible include paths for PHPUnit,
ordered from most to least desirable, and which tries each include path in turn
and then checks if the requisite classes are now loaded.
Also simplify check for PHP version: MediaWiki requires 5.3+, so might as well
assume it.
Change-Id: I9e25d69c1381cf3a87e7df2baf346bc6bb5aa052
---
M tests/phpunit/phpunit.php
1 file changed, 23 insertions(+), 23 deletions(-)
Approvals:
Addshore: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/phpunit/phpunit.php b/tests/phpunit/phpunit.php
index 7dd932f..63313cf 100755
--- a/tests/phpunit/phpunit.php
+++ b/tests/phpunit/phpunit.php
@@ -198,36 +198,36 @@
$maintClass = 'PHPUnitMaintClass';
require RUN_MAINTENANCE_IF_MAIN;
-$pharFile = stream_resolve_include_path( 'phpunit.phar' );
-$isValidPhar = Phar::isValidPharFilename( $pharFile );
-
-if ( !$isValidPhar && !class_exists( 'PHPUnit_Runner_Version' ) ) {
- // try loading phpunit via PEAR
- require_once 'PHPUnit/Runner/Version.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', '>=' )
-) {
+if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
register_shutdown_function( function () {
gc_collect_cycles();
gc_disable();
} );
}
-if ( $isValidPhar ) {
- require $pharFile;
-} else {
- if ( PHPUnit_Runner_Version::id() !== '@package_version@'
- && version_compare( PHPUnit_Runner_Version::id(), '3.7.0', '<' )
- ) {
- die( 'PHPUnit 3.7.0 or later required, you have ' .
PHPUnit_Runner_Version::id() . ".\n" );
- }
- if ( !class_exists( 'PHPUnit_TextUI_Command' ) ) {
- require_once 'PHPUnit/Autoload.php';
- }
+$ok = false;
- PHPUnit_TextUI_Command::main();
+foreach( array(
+ stream_resolve_include_path( 'phpunit.phar' ),
+ 'PHPUnit/Runner/Version.php',
+ 'PHPUnit/Autoload.php'
+) as $includePath ) {
+ @include_once( $includePath );
+ if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {
+ $ok = true;
+ break;
+ }
}
+
+if ( !$ok ) {
+ die( "Couldn't find a usable PHPUnit.\n" );
+}
+
+$puVersion = PHPUnit_Runner_Version::id();
+if ( $puVersion !== '@package_version@' && version_compare( $puVersion,
'3.7.0', '<' ) ) {
+ die( "PHPUnit 3.7.0 or later required; you have {$puVersion}.\n" );
+}
+
+PHPUnit_TextUI_Command::main();
--
To view, visit https://gerrit.wikimedia.org/r/151578
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e25d69c1381cf3a87e7df2baf346bc6bb5aa052
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits