From: Antoine Musso Date: Mon, 28 Jan 2013 15:09:17 +0000 (+0100) Subject: test: helper to skip tests depending on 'gzip' X-Git-Tag: 1.31.0-rc.0~20863^2~1 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=5a547ac784608eaa03fbc3f1b5e6cb41ed26b3ba;p=lhc%2Fweb%2Fwiklou.git test: helper to skip tests depending on 'gzip' Some of our tests explicitly depends on the 'gzip' command line utility, for example the Dumps test suite. This patch adds up a simple helper MediaWikiTestCase::checkHasGzip() which skips tests whenever gzip is missing. Change-Id: I5ded9a53d08dcf5f35e666f91e3f64e6e111af32 --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index fc51c73410..dfc58816a1 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -862,6 +862,32 @@ 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.