jenkins-bot has submitted this change and it was merged.

Change subject: Clean-up of MediaWikiTestCase::checkHasGzip()
......................................................................


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
---
M tests/phpunit/MediaWikiTestCase.php
M tests/phpunit/maintenance/DumpTestCase.php
2 files changed, 20 insertions(+), 26 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/MediaWikiTestCase.php 
b/tests/phpunit/MediaWikiTestCase.php
index e0a7ea3..8dfe628 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -1651,32 +1651,6 @@
        }
 
        /**
-        * 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.
         *
diff --git a/tests/phpunit/maintenance/DumpTestCase.php 
b/tests/phpunit/maintenance/DumpTestCase.php
index ac83d4e..1d55ab8 100644
--- a/tests/phpunit/maintenance/DumpTestCase.php
+++ b/tests/phpunit/maintenance/DumpTestCase.php
@@ -25,6 +25,26 @@
         */
        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
         *

-- 
To view, visit https://gerrit.wikimedia.org/r/292188
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iec687a6bfe75912e1875afc3abb4fb6197a0b3aa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to