https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112327

Revision: 112327
Author:   hashar
Date:     2012-02-24 15:43:11 +0000 (Fri, 24 Feb 2012)
Log Message:
-----------
avoid exif tests file leakage

Exif test are leaking files heavily on our test server. This quick patch make
it sure we delete temporary files.

Ideally, we should have something like a temporary filesystem backend that
would self destruct :-D

requires r112326: wfRecursiveRemoveDir()

Modified Paths:
--------------
    trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php

Modified: trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php
===================================================================
--- trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php      
2012-02-24 15:41:06 UTC (rev 112326)
+++ trunk/phase3/tests/phpunit/includes/media/ExifRotationTest.php      
2012-02-24 15:43:11 UTC (rev 112327)
@@ -5,11 +5,17 @@
  */
 class ExifRotationTest extends MediaWikiTestCase {
 
+       /** track directories creations. Content will be deleted. */
+       private $createdDirs = array();
+
        function setUp() {
                parent::setUp();
                $this->handler = new BitmapHandler();
                $filePath = dirname( __FILE__ ) . '/../../data/media';
+
                $tmpDir = wfTempDir() . '/exif-test-' . time() . '-' . 
mt_rand();
+               $this->createdDirs[] = $tmpDir;
+
                $this->repo = new FSRepo( array(
                        'name'            => 'temp',
                        'url'             => 'http://localhost/thumbtest',
@@ -30,12 +36,25 @@
                $this->oldAuto = $wgEnableAutoRotation;
                $wgEnableAutoRotation = true;
        }
+
        public function tearDown() {
                global $wgShowEXIF, $wgEnableAutoRotation;
                $wgShowEXIF = $this->show;
                $wgEnableAutoRotation = $this->oldAuto;
+
+               $this->tearDownFiles();
        }
 
+       private function tearDownFiles() {
+               foreach( $this->createdDirs as $dir ) {
+                       wfRecursiveRemoveDir( $dir );
+               }
+       }
+
+       function __destruct() {
+               $this->tearDownFiles();
+       }
+
        /**
         *
         * @dataProvider providerFiles


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

Reply via email to