From 9eb3359a5eebeccda37d821ba1b14d93ec89b602 Mon Sep 17 00:00:00 2001 From: "Mark A. Hershberger" Date: Tue, 5 Oct 2010 03:47:08 +0000 Subject: [PATCH] =?utf8?q?=3D=20BacklinkCache.php=20=3D=20*=20BacklinkCach?= =?utf8?q?e=20class=20**=20Set=20a=20few=20otherwise=20unset=20varables=20?= =?utf8?q?($wgContLang=20&=20$wgMemc=20in=20=20=20=20BacklinkCache)=20=3D?= =?utf8?q?=20testHelpers.inc=20=3D=20*=20TectRecorder=20class=20**=20TestR?= =?utf8?q?ecorder::record()=20accept=20and=20use=20a=20recorder=20object?= =?utf8?q?=20**=20change=20TestFileIterator::setParser=20use=20a=20MediaWi?= =?utf8?q?kiParserTest=20instead=20=20=20=20of=20ParserTest=20=3D=20parser?= =?utf8?q?Test.inc=20=3D=20*=20ParserTest=20class=20**=20Make=20$ParserTes?= =?utf8?q?t->regex=20and=20$ParsaerTest->savedGlobals=20member=20=20=20=20?= =?utf8?q?variables=20available=20to=20stop=20warnings.=20**=20Force=20Par?= =?utf8?q?serTest::$showProgress=20and=20$showFailure=20to=20false=20**=20?= =?utf8?q?Set=20ParserTest::$uploadDir=20on=20time=20**=20Move=20ParserTes?= =?utf8?q?t::chomp()=20and=20addArticle()=20to=20bootstrap=20for=20=20=20?= =?utf8?q?=20MediaWikiTestSetup.=20**=20Update=20ParserTest::runTest=20so?= =?utf8?q?=20that=20Success=20and=20Failure=20are=20reported=20=20=20=20vi?= =?utf8?q?a=20reporter->showsTestResult()=20or=20ParserTestSuiteBackend::s?= =?utf8?q?how*()=20=20=20=20as=20needed.=20**=20Set=20$ParserTest->uploadD?= =?utf8?q?ir=20with=20setupUploadDir()=20**=20Change=20ParserTest->setupGl?= =?utf8?q?obals()=20so=20that=20$wgDBprefix=20doesn't=20get=20=20=20=20to?= =?utf8?q?=20set=20to=20the=20=E2=80=9Cparsertest=5F=E2=80=9D=20bits.=20**?= =?utf8?q?=20Sprinkle=20$this->teardownGlobals()=20at=20exit=20points=20in?= =?utf8?q?=20=20=20ParserTest->teardownDatabase()=20=3D=20bootstrap.php=20?= =?utf8?q?=3D=20*=20MediaWikiTestSetup=20class=20**=20Make=20member=20vari?= =?utf8?q?ables=20MediaWikiTestSetup::$suite,=20=20=20MediaW*=20Make=20mem?= =?utf8?q?ber=20variables=20MediaWikiTestSetup::$suite,=20=20=20MediaWikiT?= =?utf8?q?estSetup::$regex,=20MediaWikiTestSetup::$runDisabled=20=20=20ava?= =?utf8?q?ilable.=20*=20Setup=20a=20constructor=20MediaWikiTestSetup=20tha?= =?utf8?q?t=20accepts=20an=20optional=20=20=20PHPUnit=5FFramework=5FTestSu?= =?utf8?q?ite=20so=20they=20can=20use=20PHPUnit.=20*=20Change=20MediaWikiP?= =?utf8?q?arserTest=20so=20that=20it=20is=20derived=20from=20=20=20MediaWi?= =?utf8?q?kiTestSetup=20instead=20of=20PHPUnit=5FFramework=5FTestSuite=20*?= =?utf8?q?=20Make=20MediaWikiParserTest=20create=20a=20PHPUnit=5FFramework?= =?utf8?q?=5FTestSuite=20for=20=20=20the=20parser=20tests=20and=20pass=20i?= =?utf8?q?t=20to=20the=20new=20parent=20(MediaWikiTestSetup)=20=20=20as=20?= =?utf8?q?the=20PHPUnit=20testsuite.=20*=20Replace=20MediaWikiParserTest->?= =?utf8?q?run()=20with=20MediaWikiParserTest::suite()=20=20=20so=20that=20?= =?utf8?q?the=20tests=20can=20be=20loaded=20into=20a=20suite=20and=20then?= =?utf8?q?=20run=20with=20=20=20PHPUnit's=20test=20runner.=20=3D=20ParserH?= =?utf8?q?elpers.php=20=3D=20*=20ParserUnitTest=20class=20**=20Force=20run?= =?utf8?q?()=20$backend=20to=20use=20ParserTestSuiteBackend=20instead=20of?= =?utf8?q?=20=20=20=20trying=20to=20get=20the=20=20backend=20from=20the=20?= =?utf8?q?suite=20member.=20**=20Use=20ParserTest::runTest()=20instead=20o?= =?utf8?q?f=20=20=20ParserikiTestSetup::$regex,=20MediaWikiTestSetup::$run?= =?utf8?q?Disabled=20=20=20available.=20**=20Setup=20a=20constructor=20Med?= =?utf8?q?iaWikiTestSetup=20that=20accepts=20an=20optional=20=20=20=20PHPU?= =?utf8?q?nit=5FFramework=5FTestSuite=20so=20they=20can=20use=20PHPUnit.?= =?utf8?q?=20**=20Change=20MediaWikiParserTest=20so=20that=20it=20is=20der?= =?utf8?q?ived=20from=20=20=20=20MediaWikiTestSetup=20instead=20of=20PHPUn?= =?utf8?q?it=5FFramework=5FTestSuite=20**=20Make=20MediaWikiParserTest=20c?= =?utf8?q?reate=20a=20PHPUnit=5FFramework=5FTestSuite=20for=20=20=20=20the?= =?utf8?q?=20parser=20tests=20and=20pass=20it=20to=20the=20new=20parent=20?= =?utf8?q?(MediaWikiTestSetup)=20=20=20=20as=20the=20PHPUnit=20testsuite.?= =?utf8?q?=20**=20Replace=20MediaWikiParserTest->run()=20with=20MediaWikiP?= =?utf8?q?arserTest::suite()=20=20=20=20so=20that=20the=20tests=20can=20be?= =?utf8?q?=20loaded=20into=20a=20suite=20and=20then=20run=20with=20=20=20?= =?utf8?q?=20PHPUnit's=20test=20runner.=20=3D=20ParserHelpers.php=20=3D=20?= =?utf8?q?*=20ParserUnitTest=20class=20**=20Force=20run()=20$backend=20to?= =?utf8?q?=20use=20ParserTestSuiteBackend=20instead=20of=20=20=20=20trying?= =?utf8?q?=20to=20get=20the=20=20backend=20from=20the=20suite=20member.=20?= =?utf8?q?**=20Use=20ParserTest::runTest()=20instead=20of=20=20=20ParserTe?= =?utf8?q?stSuiteBackend::runTest()=20*=20ParserTestSuiteBackend=20class?= =?utf8?q?=20**=20extends=20PHPUnit=5FFrameWork=5FTestSuite=20instead=20of?= =?utf8?q?=20ParserTest=20**=20Add=20member=20variables=20=20$recorder,=20?= =?utf8?q?$term,=20and=20$usePHPUnit=20**=20Add=20a=20constructor=20that?= =?utf8?q?=20determines=20if=20PHPUnit=20is=20usewd.=20**=20Add=20a=20meth?= =?utf8?q?od=20showTestResult()=20that=20can=20be=20used=20to=20show=20suc?= =?utf8?q?cess=20or=20=20=20=20failure=20**=20Change=20showSucess=20and=20?= =?utf8?q?showFailure()=20to=20be=20static=20and=20use=20identical=20=20?= =?utf8?q?=20=20arguments=20and=20only=20use=20PHPUnit=5FFramework=5FAsser?= =?utf8?q?t::assertEquals=20=20=20=20when=20PHPUnit=20is=20in=20use.=20=3D?= =?utf8?q?=20SearchEngineTest.php=20=3D=20**=20Fix=20path=20in=20require?= =?utf8?q?=20to=20bootstrap.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- maintenance/tests/parser/parserTest.inc | 48 ++++++++++++------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/maintenance/tests/parser/parserTest.inc b/maintenance/tests/parser/parserTest.inc index faa4c72fe7..5bf3ef027b 100644 --- a/maintenance/tests/parser/parserTest.inc +++ b/maintenance/tests/parser/parserTest.inc @@ -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(); } /** -- 2.20.1