From: Antoine Musso Date: Fri, 24 Feb 2012 15:43:11 +0000 (+0000) Subject: avoid exif tests file leakage X-Git-Tag: 1.31.0-rc.0~24542 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=f5b45904e119a7a296011d45da54f197bfcdd13f;p=lhc%2Fweb%2Fwiklou.git 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() --- 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(); } /**