Clean-up of MediaWikiTestCase::checkHasGzip()
* Move the method from MediaWikiTestCase to DumpTestCase. Only subclasses of DumpTestCase use it, and it is not sufficiently well-designed to be a part of MediaWikiTestCase. (I'd want something more generic, like "$this->markSkippedUnlessExecutable()", rather than a method dedicated solely to establishing the availability of the gzip binary.) * Fix it so that the result of the check is actually cached. It wasn't, previously, because of how 'static' works in PHP. * Be content with checking that gzip is in $PATH instead of actually executing it. Change-Id: Iec687a6bfe75912e1875afc3abb4fb6197a0b3aa
This commit is contained in:
parent
873def9a99
commit
b19ff38846
2 changed files with 20 additions and 26 deletions
|
|
@ -1650,32 +1650,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we have the 'gzip' commandline utility, will skip
|
||||
* the test whenever "gzip -V" fails.
|
||||
*
|
||||
* Result is cached at the process level.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.21
|
||||
*/
|
||||
protected function checkHasGzip() {
|
||||
static $haveGzip;
|
||||
|
||||
if ( $haveGzip === null ) {
|
||||
$retval = null;
|
||||
wfShellExec( 'gzip -V', $retval );
|
||||
$haveGzip = ( $retval === 0 );
|
||||
}
|
||||
|
||||
if ( !$haveGzip ) {
|
||||
$this->markTestSkipped( "Skip test, requires the gzip utility in PATH" );
|
||||
}
|
||||
|
||||
return $haveGzip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if $extName is a loaded PHP extension, will skip the
|
||||
* test whenever it is not loaded.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,26 @@ abstract class DumpTestCase extends MediaWikiLangTestCase {
|
|||
*/
|
||||
protected $xml = null;
|
||||
|
||||
/** @var bool|null Whether the 'gzip' utility is available */
|
||||
protected static $hasGzip = null;
|
||||
|
||||
/**
|
||||
* Skip the test if 'gzip' is not in $PATH.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkHasGzip() {
|
||||
if ( self::$hasGzip === null ) {
|
||||
self::$hasGzip = ( Installer::locateExecutableInDefaultPaths( 'gzip' ) !== false );
|
||||
}
|
||||
|
||||
if ( !self::$hasGzip ) {
|
||||
$this->markTestSkipped( "Skip test, requires the gzip utility in PATH" );
|
||||
}
|
||||
|
||||
return self::$hasGzip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a revision to a page, while returning the resuting revision's id
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue