= BacklinkCache.php =
[lhc/web/wiklou.git] / maintenance / tests / parser / parserTest.inc
index faa4c72..5bf3ef0 100644 (file)
@@ -57,6 +57,9 @@ class ParserTest {
        private $fuzzSeed = 0;
        private $memoryLimit = 50;
 
+       public $regex = "";
+       private $savedGlobals = array();
+
        /**
         * Sets terminal colorization and diff/quick modes depending on OS and
         * command-line options (--color and --quick).
@@ -82,15 +85,14 @@ class ParserTest {
                        : new DummyTermColorer();
 
                $this->showDiffs = !isset( $options['quick'] );
-               $this->showProgress = !isset( $options['quiet'] );
-               $this->showFailure = !(
-                       isset( $options['quiet'] )
-                       && ( isset( $options['record'] )
-                               || isset( $options['compare'] ) ) ); // redundant output
+               $this->showProgress = false; #!isset( $options['quiet'] );
+               $this->showFailure = false; /* !( */
+                       /* isset( $options['quiet'] ) */
+                       /* && ( isset( $options['record'] ) */
+                       /*      || isset( $options['compare'] ) ) ); // redundant output */
 
                $this->showOutput = isset( $options['show-output'] );
 
-
                if ( isset( $options['regex'] ) ) {
                        if ( isset( $options['record'] ) ) {
                                echo "Warning: --record cannot be used with --regex, disabling --record\n";
@@ -104,6 +106,7 @@ class ParserTest {
 
                $this->setupRecorder( $options );
                $this->keepUploads = isset( $options['keep-uploads'] );
+               $this->uploadDir = $this->setupUploadDir();
 
                if ( isset( $options['seed'] ) ) {
                        $this->fuzzSeed = intval( $options['seed'] ) - 1;
@@ -129,18 +132,6 @@ class ParserTest {
                }
        }
 
-       /**
-        * Remove last character if it is a newline
-        */
-       public function chomp( $s ) {
-               if ( substr( $s, -1 ) === "\n" ) {
-                       return substr( $s, 0, -1 );
-               }
-               else {
-                       return $s;
-               }
-       }
-
        /**
         * Run a fuzz test series
         * Draw input from a set of test files
@@ -422,12 +413,12 @@ class ParserTest {
                }
 
 
-               $this->teardownGlobals();
-
-               if ( $result === $out && ( $noxml === true || $this->wellFormed( $out ) ) ) {
-                       return $this->showSuccess( $desc );
+               if ( method_exists( $this->recorder, "showTestResult" ) ) {
+                       return $this->recorder->showTestResult( $desc, $result, $out );
+               } else if ( $result === $out && ( $noxml === true || $this->wellFormed( $out ) ) ) {
+                       return ParserTestSuiteBackend::showSuccess( $desc, $result, $out );
                } else {
-                       return $this->showFailure( $desc, $result, $out );
+                       return ParserTestSuiteBackend::showFailure( $desc, $result, $out );
                }
        }
 
@@ -550,7 +541,6 @@ class ParserTest {
                        'wgStyleSheetPath' => '/skins',
                        'wgSitename' => 'MediaWiki',
                        'wgLanguageCode' => $lang,
-                       'wgDBprefix' => $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_',
                        'wgRawHtml' => isset( $opts['rawhtml'] ),
                        'wgLang' => null,
                        'wgContLang' => null,
@@ -712,7 +702,10 @@ class ParserTest {
                if ( $wgDBtype == 'oracle' )
                        $db->query( 'BEGIN FILL_WIKI_INFO; END;' );
 
-               $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
+               if ( ( $wgDBtype != 'oracle' && $wgDBprefix != 'parsertest_' )
+                       && $wgDBprefix != 'pt_' ) {
+                       $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' );
+               }
 
                # Hack: insert a few Wikipedia in-project interwiki prefixes,
                # for testing inter-language links
@@ -769,7 +762,6 @@ class ParserTest {
                global $wgMessageCache, $wgMemc;
                $wgMessageCache = new MessageCache( $wgMemc, true, 3600 );
 
-               $this->uploadDir = $this->setupUploadDir();
                $user = User::createNew( 'WikiSysop' );
                $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) );
                $image->recordUpload2( '', 'Upload of some lame file', 'Some lame file', array(
@@ -820,6 +812,7 @@ class ParserTest {
                global $wgDBtype;
 
                if ( !$this->databaseSetupDone ) {
+                       $this->teardownGlobals();
                        return;
                }
                $this->teardownUploadDir( $this->uploadDir );
@@ -829,6 +822,7 @@ class ParserTest {
 
                if ( $this->useTemporaryTables ) {
                        # Don't need to do anything
+                       $this->teardownGlobals();
                        return;
                }
 
@@ -842,6 +836,8 @@ class ParserTest {
 
                if ( $wgDBtype == 'oracle' )
                        $db->query( 'BEGIN FILL_WIKI_INFO; END;' );
+
+               $this->teardownGlobals();
        }
 
        /**