Index: trunk/phase3/maintenance/parserTests.inc |
— | — | @@ -95,6 +95,7 @@ |
96 | 96 | } else { |
97 | 97 | $this->recorder = new TestRecorder( $this->term ); |
98 | 98 | } |
| 99 | + $this->keepUploads = isset( $options['keep-uploads'] ); |
99 | 100 | |
100 | 101 | $this->hooks = array(); |
101 | 102 | $this->functionHooks = array(); |
— | — | @@ -280,7 +281,7 @@ |
281 | 282 | |
282 | 283 | $noxml = (bool)preg_match( '~\\b noxml \\b~x', $opts ); |
283 | 284 | |
284 | | - $parser = new Parser(); |
| 285 | + $parser = new Parser; |
285 | 286 | foreach( $this->hooks as $tag => $callback ) { |
286 | 287 | $parser->setHook( $tag, $callback ); |
287 | 288 | } |
— | — | @@ -297,11 +298,11 @@ |
298 | 299 | $out = $parser->preSaveTransform( $input, $title, $user, $options ); |
299 | 300 | } elseif (preg_match('/\\bmsg\\b/i', $opts)) { |
300 | 301 | $out = $parser->transformMsg( $input, $options ); |
301 | | - } elseif( preg_match( '/\\bsection=(\d+)\b/i', $opts, $matches ) ) { |
302 | | - $section = intval( $matches[1] ); |
| 302 | + } elseif( preg_match( '/\\bsection=([\w-]+)\b/i', $opts, $matches ) ) { |
| 303 | + $section = $matches[1]; |
303 | 304 | $out = $parser->getSection( $input, $section ); |
304 | | - } elseif( preg_match( '/\\breplace=(\d+),"(.*?)"/i', $opts, $matches ) ) { |
305 | | - $section = intval( $matches[1] ); |
| 305 | + } elseif( preg_match( '/\\breplace=([\w-]+),"(.*?)"/i', $opts, $matches ) ) { |
| 306 | + $section = $matches[1]; |
306 | 307 | $replace = $matches[2]; |
307 | 308 | $out = $parser->replaceSection( $input, $section, $replace ); |
308 | 309 | } else { |
— | — | @@ -550,7 +551,15 @@ |
551 | 552 | */ |
552 | 553 | private function setupUploadDir() { |
553 | 554 | global $IP; |
554 | | - $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images"; |
| 555 | + if ( $this->keepUploads ) { |
| 556 | + $dir = wfTempDir() . '/mwParser-images'; |
| 557 | + if ( is_dir( $dir ) ) { |
| 558 | + return $dir; |
| 559 | + } |
| 560 | + } else { |
| 561 | + $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images"; |
| 562 | + } |
| 563 | + |
555 | 564 | wfDebug( "Creating upload directory $dir\n" ); |
556 | 565 | mkdir( $dir ); |
557 | 566 | mkdir( $dir . '/3' ); |
— | — | @@ -578,6 +587,10 @@ |
579 | 588 | * Remove the dummy uploads directory |
580 | 589 | */ |
581 | 590 | private function teardownUploadDir( $dir ) { |
| 591 | + if ( $this->keepUploads ) { |
| 592 | + return; |
| 593 | + } |
| 594 | + |
582 | 595 | // delete the files first, then the dirs. |
583 | 596 | self::deleteFiles( |
584 | 597 | array ( |
Index: trunk/phase3/maintenance/parserTests.php |
— | — | @@ -42,6 +42,7 @@ |
43 | 43 | --file Run test cases from a custom file instead of parserTests.txt |
44 | 44 | --record Record tests in database |
45 | 45 | --compare Compare with recorded results, without updating the database. |
| 46 | + --keep-uploads Re-use the same upload directory for each test, don't delete it |
46 | 47 | --help Show this help message |
47 | 48 | |
48 | 49 | |