From f5b45904e119a7a296011d45da54f197bfcdd13f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 24 Feb 2012 15:43:11 +0000 Subject: [PATCH] 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() --- .../includes/media/ExifRotationTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/phpunit/includes/media/ExifRotationTest.php b/tests/phpunit/includes/media/ExifRotationTest.php index a703493a79..25149a0573 100644 --- a/tests/phpunit/includes/media/ExifRotationTest.php +++ b/tests/phpunit/includes/media/ExifRotationTest.php @@ -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,10 +36,23 @@ class ExifRotationTest extends MediaWikiTestCase { $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(); } /** -- 2.20.1