r112354 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112353‎ | r112354 | r112355 >
Date:20:38, 24 February 2012
Author:hashar
Status:ok
Tags:
Comment:
MFT to REL1_19 fix tests leaking files

Merges: r112326 r112327 r112352

This is needed since WMF continuouos integration server runs REL1_19
test suite.
Modified paths:
  • /branches/REL1_19/phase3/includes/GlobalFunctions.php (modified) (history)
  • /branches/REL1_19/phase3/includes/SeleniumWebSettings.php (modified) (history)
  • /branches/REL1_19/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php (modified) (history)
  • /branches/REL1_19/phase3/tests/phpunit/includes/media/ExifRotationTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_19/phase3/tests/phpunit/includes/filerepo/FileBackendTest.php
@@ -200,6 +200,7 @@
201201 $this->backend = $this->multiBackend;
202202 $this->tearDownFiles();
203203 $this->doTestStore( $op );
 204+ $this->filesToPrune[] = $op['src']; # avoid file leaking
204205 $this->tearDownFiles();
205206 }
206207
@@ -662,6 +663,7 @@
663664 $this->backend = $this->multiBackend;
664665 $this->tearDownFiles();
665666 $this->doTestConcatenate( $op, $srcs, $srcsContent, $alreadyExists, $okStatus );
 667+ $this->filesToPrune[] = $op['dst']; # avoid file leaking
666668 $this->tearDownFiles();
667669 }
668670
Index: branches/REL1_19/phase3/tests/phpunit/includes/media/ExifRotationTest.php
@@ -5,11 +5,17 @@
66 */
77 class ExifRotationTest extends MediaWikiTestCase {
88
 9+ /** track directories creations. Content will be deleted. */
 10+ private $createdDirs = array();
 11+
912 function setUp() {
1013 parent::setUp();
1114 $this->handler = new BitmapHandler();
1215 $filePath = dirname( __FILE__ ) . '/../../data/media';
 16+
1317 $tmpDir = wfTempDir() . '/exif-test-' . time() . '-' . mt_rand();
 18+ $this->createdDirs[] = $tmpDir;
 19+
1420 $this->repo = new FSRepo( array(
1521 'name' => 'temp',
1622 'url' => 'http://localhost/thumbtest',
@@ -30,12 +36,25 @@
3137 $this->oldAuto = $wgEnableAutoRotation;
3238 $wgEnableAutoRotation = true;
3339 }
 40+
3441 public function tearDown() {
3542 global $wgShowEXIF, $wgEnableAutoRotation;
3643 $wgShowEXIF = $this->show;
3744 $wgEnableAutoRotation = $this->oldAuto;
 45+
 46+ $this->tearDownFiles();
3847 }
3948
 49+ private function tearDownFiles() {
 50+ foreach( $this->createdDirs as $dir ) {
 51+ wfRecursiveRemoveDir( $dir );
 52+ }
 53+ }
 54+
 55+ function __destruct() {
 56+ $this->tearDownFiles();
 57+ }
 58+
4059 /**
4160 *
4261 * @dataProvider providerFiles
Index: branches/REL1_19/phase3/includes/SeleniumWebSettings.php
@@ -201,21 +201,3 @@
202202 $testUploadPath = getTestUploadPathFromResourceName( $testResourceName );
203203 $wgUploadPath = $testUploadPath;
204204 }
205 -
206 -function wfRecursiveRemoveDir( $dir ) {
207 - // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
208 - if ( is_dir( $dir ) ) {
209 - $objects = scandir( $dir );
210 - foreach ( $objects as $object ) {
211 - if ( $object != "." && $object != ".." ) {
212 - if ( filetype( $dir . '/' . $object ) == "dir" ) {
213 - wfRecursiveRemoveDir( $dir . '/' . $object );
214 - } else {
215 - unlink( $dir . '/' . $object );
216 - }
217 - }
218 - }
219 - reset( $objects );
220 - rmdir( $dir );
221 - }
222 -}
\ No newline at end of file
Index: branches/REL1_19/phase3/includes/GlobalFunctions.php
@@ -2589,6 +2589,29 @@
25902590 }
25912591
25922592 /**
 2593+ * Remove a directory and all its content.
 2594+ * Does not hide error.
 2595+ */
 2596+function wfRecursiveRemoveDir( $dir ) {
 2597+ wfDebug( __FUNCTION__ . "( $dir )\n" );
 2598+ // taken from http://de3.php.net/manual/en/function.rmdir.php#98622
 2599+ if ( is_dir( $dir ) ) {
 2600+ $objects = scandir( $dir );
 2601+ foreach ( $objects as $object ) {
 2602+ if ( $object != "." && $object != ".." ) {
 2603+ if ( filetype( $dir . '/' . $object ) == "dir" ) {
 2604+ wfRecursiveRemoveDir( $dir . '/' . $object );
 2605+ } else {
 2606+ unlink( $dir . '/' . $object );
 2607+ }
 2608+ }
 2609+ }
 2610+ reset( $objects );
 2611+ rmdir( $dir );
 2612+ }
 2613+}
 2614+
 2615+/**
25932616 * @param $nr Mixed: the number to format
25942617 * @param $acc Integer: the number of digits after the decimal point, default 2
25952618 * @param $round Boolean: whether or not to round the value, default true
Property changes on: branches/REL1_19/phase3/includes/GlobalFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
25962619 Merged /trunk/phase3/includes/GlobalFunctions.php:r112326-112327,112352

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112326move wfRecursiveRemoveDir to global functions...hashar15:41, 24 February 2012
r112327avoid exif tests file leakage...hashar15:43, 24 February 2012
r112352avoid test suite file leakshashar20:30, 24 February 2012

Status & tagging log