r76134 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76133‎ | r76134 | r76135 >
Date:20:03, 5 November 2010
Author:platonides
Status:deferred (Comments)
Tags:
Comment:
Follow up r75810. The code for the parser tests modified the main database even when they were not run.
They are now lazy loaded on the first parserTest. This should also make running the other parserTests faster.
It shouldn't take that memory or even parse ParserTests.txt if they are not going to be run, though.

PHPUnit ParserTests are still broken at this point due to r74646
Modified paths:
  • /trunk/phase3/maintenance/tests/parser/parserTest.inc (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/parser/ParserHelpers.php (modified) (history)
  • /trunk/phase3/maintenance/tests/testHelpers.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/parser/ParserHelpers.php
@@ -33,6 +33,7 @@
3434 $result = new PHPUnit_Framework_TestResult;
3535 }
3636
 37+ $this->suite->publishTestArticles(); // Add articles needed by the tests.
3738 $backend = new ParserTestSuiteBackend;
3839 $result->startTest( $this );
3940
Index: trunk/phase3/maintenance/tests/phpunit/includes/parser/MediaWikiParserTest.php
@@ -4,8 +4,9 @@
55 require_once( dirname(dirname(dirname( __FILE__ ))) . '/bootstrap.php' );
66
77 class MediaWikiParserTest extends MediaWikiTestSetup {
8 - public $count;
9 - public $backend;
 8+ public $count; // Number of tests in the suite.
 9+ public $backend; // ParserTestSuiteBackend instance
 10+ public $articles = array(); // Array of test articles defined by the tests
1011
1112 public function __construct() {
1213 $suite = new PHPUnit_Framework_TestSuite('Parser Tests');
@@ -24,7 +25,7 @@
2526 $tester->count = 0;
2627
2728 foreach ( $iter as $test ) {
28 - $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Broken' ) );
 29+ $tester->suite->addTest( new ParserUnitTest( $tester, $test ), array( 'Parser', 'Destructive', 'Database', 'Broken' ) );
2930 $tester->count++;
3031 }
3132
@@ -46,5 +47,24 @@
4748 public function getIterator() {
4849 return $this->iterator;
4950 }
 51+
 52+ public function publishTestArticles() {
 53+ if ( empty( $this->articles ) ) {
 54+ return;
 55+ }
 56+
 57+ foreach ( $this->articles as $name => $text ) {
 58+ $title = Title::newFromText( $name );
 59+
 60+ if ( $title->getArticleID( Title::GAID_FOR_UPDATE ) == 0 ) {
 61+ ParserTest::addArticle( $name, $text );
 62+ }
 63+ }
 64+ $this->articles = array();
 65+ }
 66+
 67+ public function addArticle( $name, $text, $line ) {
 68+ $this->articles[$name] = $text;
 69+ }
5070 }
5171
Index: trunk/phase3/maintenance/tests/testHelpers.inc
@@ -536,10 +536,11 @@
537537 wfDie( "'endarticle' without 'article' at line {$this->lineNum} of $this->file\n" );
538538 }
539539
540 - $title = Title::newFromText( ParserTest::chomp( $data['article'] ) );
541 - $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
542 - if ( $aid == 0 )
 540+ if ( $this->parser ) {
 541+ $this->parser->addArticle( ParserTest::chomp( $data['article'] ), $data['text'], $this->lineNum );
 542+ } else {
543543 ParserTest::addArticle( $data['article'], $data['text'], $this->lineNum );
 544+ }
544545 $data = array();
545546 $section = null;
546547
Index: trunk/phase3/maintenance/tests/parser/parserTest.inc
@@ -1154,7 +1154,7 @@
11551155 * @param $text String: the article text
11561156 * @param $line Integer: the input line number, for reporting errors
11571157 */
1158 - static public function addArticle( $name, $text, $line ) {
 1158+ static public function addArticle( $name, $text, $line = 'unknown' ) {
11591159 global $wgCapitalLinks;
11601160
11611161 $text = self::chomp($text);

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74646NOTE THAT THIS COMMIT REVEALS FAILING PARSER TESTS WHEN THEY ARE RUN IN PHPUn...mah22:50, 11 October 2010
r75810Modified the tests so that a database is not unnecessarily required....platonides18:23, 1 November 2010

Comments

#Comment by MarkAHershberger (talk | contribs)   16:59, 6 November 2010

Thanks for looking at this. I spent some time yesterday on the "modifying the database" problem and suspect I'll be spending a bit more problem on it yet.

#Comment by Platonides (talk | contribs)   18:10, 6 November 2010

I think that fixing phpunit parser tests is more important now.

The database switching could be done quite well in phpunit.php, I think.

#Comment by MarkAHershberger (talk | contribs)   00:15, 7 November 2010

Agreed. And, despite how I phrased my response, that is how I spent the time.

#Comment by Platonides (talk | contribs)   00:34, 7 November 2010
) :)

Status & tagging log