r17687 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17686‎ | r17687 | r17688 >
Date:04:06, 15 November 2006
Author:nickj
Status:old
Tags:
Comment:
* Add printing the names of tests whose status has just changed when using "--record" option.
* Make $wgRawHtml testable by parserTests.
* Add a variety of new tests, some of which will fail and some of which will succeed. (Please feel free to edit expected test results if you think they are wrong, especially the subpage ones).
Modified paths:
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
@@ -370,7 +370,7 @@
371371 'wgLanguageCode' => $lang,
372372 'wgContLanguageCode' => $lang,
373373 'wgDBprefix' => 'parsertest_',
374 -
 374+ 'wgRawHtml' => preg_match('/\\brawhtml\\b/i', $opts),
375375 'wgLang' => null,
376376 'wgContLang' => null,
377377 'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)),
@@ -843,6 +843,7 @@
844844 }
845845 }
846846
 847+/* A colour-less terminal */
847848 class DummyTermColorer {
848849 function color( $color ) {
849850 return '';
@@ -894,9 +895,9 @@
895896 }
896897
897898 class DbTestRecorder extends TestRecorder {
898 - var $db; ///< Database connection to the main DB
899 - var $curRun; ///< run ID number for the current run
900 - var $prevRun; ///< run ID number for the previous run, if any
 899+ private $db; ///< Database connection to the main DB
 900+ private $curRun; ///< run ID number for the current run
 901+ private $prevRun; ///< run ID number for the previous run, if any
901902
902903 function __construct( $term ) {
903904 parent::__construct( $term );
@@ -962,11 +963,15 @@
963964 array( 'previously FAILING test(s) removed O_o', 0, null ),
964965 array( 'new FAILING test(s) :(', null, 0 ),
965966 );
966 - foreach( $table as $blah ) {
967 - list( $label, $before, $after ) = $blah;
968 - $count = $this->comparisonCount( $before, $after );
969 - if( $count ) {
 967+ foreach( $table as $criteria ) {
 968+ list( $label, $before, $after ) = $criteria;
 969+ $differences = $this->compareResult( $before, $after );
 970+ if( $differences ) {
 971+ $count = count($differences);
970972 printf( "%4d %s\n", $count, $label );
 973+ foreach ($differences as $differing_test_name) {
 974+ print " * $differing_test_name\n";
 975+ }
971976 }
972977 }
973978 } else {
@@ -976,19 +981,20 @@
977982 }
978983
979984 /**
980 - * :P
 985+ ** @desc: Returns an array of the test names with changed results, based on the specified
 986+ ** before/after criteria.
981987 */
982 - private function comparisonCount( $before, $after ) {
 988+ private function compareResult( $before, $after ) {
983989 $testitem = $this->db->tableName( 'testitem' );
984990 $prevRun = intval( $this->prevRun );
985991 $curRun = intval( $this->curRun );
986992 $prevStatus = $this->condition( $before );
987993 $curStatus = $this->condition( $after );
988994
989 - // note: requires a current mysql for subselects
 995+ // note: requires mysql >= ver 4.1 for subselects
990996 if( is_null( $after ) ) {
991997 $sql = "
992 - select count(*) as c from $testitem as prev
 998+ select prev.ti_name as t from $testitem as prev
993999 where prev.ti_run=$prevRun and
9941000 prev.ti_success $prevStatus and
9951001 (select current.ti_success from $testitem as current
@@ -996,7 +1002,7 @@
9971003 and prev.ti_name=current.ti_name) $curStatus";
9981004 } else {
9991005 $sql = "
1000 - select count(*) as c from $testitem as current
 1006+ select current.ti_name as t from $testitem as current
10011007 where current.ti_run=$curRun and
10021008 current.ti_success $curStatus and
10031009 (select prev.ti_success from $testitem as prev
@@ -1004,11 +1010,17 @@
10051011 and prev.ti_name=current.ti_name) $prevStatus";
10061012 }
10071013 $result = $this->db->query( $sql, __METHOD__ );
1008 - $row = $this->db->fetchObject( $result );
 1014+ $retval = array();
 1015+ while ($row = $this->db->fetchObject( $result )) {
 1016+ $retval[] = $row->t;
 1017+ }
10091018 $this->db->freeResult( $result );
1010 - return $row->c;
 1019+ return $retval;
10111020 }
10121021
 1022+ /**
 1023+ ** @desc: Helper function for compareResult() database querying.
 1024+ */
10131025 private function condition( $value ) {
10141026 if( is_null( $value ) ) {
10151027 return 'IS NULL';
Index: trunk/phase3/maintenance/parserTests.txt
@@ -5871,7 +5871,222 @@
58725872
58735873 !!end
58745874
 5875+!! test
 5876+[Before] HTML without raw HTML enabled ($wgRawHtml==false)
 5877+!! input
 5878+<html><script>alert(1);</script></html>
 5879+!! result
 5880+<p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
 5881+</p>
 5882+!! end
58755883
 5884+!! test
 5885+HTML with raw HTML ($wgRawHtml==true)
 5886+!! options
 5887+rawhtml
 5888+!! input
 5889+<html><script>alert(1);</script></html>
 5890+!! result
 5891+<p><script>alert(1);</script>
 5892+</p>
 5893+!! end
 5894+
 5895+!! test
 5896+Parents of subpages, one level up
 5897+!! options
 5898+subpage title=[[Subpage test/L1/L2/L3]]
 5899+!! input
 5900+[[../|L2]]
 5901+!! result
 5902+<p><a href="https://www.mediawiki.org/index.php?title=Subpage_test/L1/L2&amp;action=edit" class="new" title="Subpage test/L1/L2">L2</a>
 5903+</p>
 5904+!! end
 5905+
 5906+
 5907+!! test
 5908+Parents of subpages, one level up, not named
 5909+!! options
 5910+subpage title=[[Subpage test/L1/L2/L3]]
 5911+!! input
 5912+[[../]]
 5913+!! result
 5914+<p><a href="https://www.mediawiki.org/index.php?title=Subpage_test/L1/L2&amp;action=edit" class="new" title="Subpage test/L1/L2">Subpage test/L1/L2</a>
 5915+</p>
 5916+!! end
 5917+
 5918+
 5919+
 5920+!! test
 5921+Parents of subpages, two levels up
 5922+!! options
 5923+disabled
 5924+subpage title=[[Subpage test/L1/L2/L3]]
 5925+!! input
 5926+[[../../|L1]]2
 5927+!! result
 5928+<p><a href="https://www.mediawiki.org/index.php?title=Subpage_test/L1&amp;action=edit" class="new" title="Subpage test/L1">L1</a>
 5929+</p>
 5930+!! end
 5931+
 5932+
 5933+# Question: should result be "/index.php?title=Subpage_test/L1&amp;action=edit" instead?
 5934+!! test
 5935+TODO: Parents of subpages, two levels up, without trailing slash or name.
 5936+!! options
 5937+subpage title=[[Subpage test/L1/L2/L3]]
 5938+!! input
 5939+[[../..]]
 5940+!! result
 5941+<p><a href="https://www.mediawiki.org/index.php?title=Subpage_test/L1/L2/..&amp;action=edit" class="new" title="Subpage test/L1">../..</a>
 5942+</p>
 5943+!! end
 5944+
 5945+# Question: Why should the link text in the above test be "../..", yet in this test the "../.." part is silently dropped?
 5946+# Current result: <p><a href="https://www.mediawiki.org/index.php?title=Subpage_test/L1////&amp;action=edit" class="new" title="Subpage test/L1////">///
 5947+!! test
 5948+TODO: Parents of subpages, two levels up, with lots of extra trailing slashes.
 5949+!! options
 5950+subpage title=[[Subpage test/L1/L2/L3]]
 5951+!! input
 5952+[[../../////]]
 5953+!! result
 5954+<p><a href="https://www.mediawiki.org/index.php?title=Subpage_test/L1&amp;action=edit" class="new" title="Subpage test/L1">Subpage test/L1</a>
 5955+</p>
 5956+!! end
 5957+
 5958+!! test
 5959+Definition list code coverage
 5960+!! input
 5961+; title : def
 5962+; title : def
 5963+;title: def
 5964+!! result
 5965+<dl><dt> title &nbsp;</dt><dd> def
 5966+</dd><dt> title&nbsp;</dt><dd> def
 5967+</dd><dt>title</dt><dd> def
 5968+</dd></dl>
 5969+
 5970+!! end
 5971+
 5972+!! test
 5973+TODO: Don't fall for the self-closing div
 5974+!! input
 5975+<div>hello world</div/>
 5976+!! result
 5977+<div>hello world</div>
 5978+
 5979+!! end
 5980+
 5981+!! test
 5982+MSGNW magic word
 5983+!! input
 5984+{{MSGNW:msg}}
 5985+!! result
 5986+<p>&#91;&#91;:Template:Msg]]
 5987+</p>
 5988+!! end
 5989+
 5990+!! test
 5991+RAW magic word
 5992+!! input
 5993+{{RAW:QUERTY}}
 5994+!! result
 5995+<p><a href="https://www.mediawiki.org/index.php?title=Template:QUERTY&amp;action=edit" class="new" title="Template:QUERTY">Template:QUERTY</a>
 5996+</p>
 5997+!! end
 5998+
 5999+!! test
 6000+TODO: Always escape literal '>' in output, not just after '<'
 6001+!! input
 6002+><>
 6003+!! result
 6004+<p>&gt;&lt;&gt;
 6005+</p>
 6006+!! end
 6007+
 6008+!! test
 6009+Template caching
 6010+!! input
 6011+{{Test}}
 6012+{{Test}}
 6013+!! result
 6014+<p>This is a test template
 6015+This is a test template
 6016+</p>
 6017+!! end
 6018+
 6019+
 6020+!! article
 6021+MediaWiki:Fake
 6022+!! text
 6023+==header==
 6024+!! endarticle
 6025+
 6026+!! test
 6027+Inclusion of !userCanEdit() content
 6028+!! input
 6029+{{MediaWiki:Fake}}
 6030+!! result
 6031+<a name="header"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=MediaWiki:Fake&amp;action=edit&amp;section=1" title="MediaWiki:Fake">edit</a>]</span> <span class="mw-headline">header</span></h2>
 6032+
 6033+!! end
 6034+
 6035+
 6036+!! test
 6037+Out-of-order TOC heading levels
 6038+!! input
 6039+==2==
 6040+======6======
 6041+===3===
 6042+=1=
 6043+=====5=====
 6044+==2==
 6045+!! result
 6046+<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
 6047+<ul>
 6048+<li class="toclevel-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
 6049+<ul>
 6050+<li class="toclevel-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
 6051+<li class="toclevel-2"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
 6052+</ul>
 6053+</li>
 6054+<li class="toclevel-1"><a href="#1_7"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
 6055+<ul>
 6056+<li class="toclevel-2"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
 6057+<li class="toclevel-2"><a href="#2_4"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
 6058+</ul>
 6059+</li>
 6060+</ul>
 6061+</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
 6062+<a name="2"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 2">edit</a>]</span> <span class="mw-headline">2</span></h2>
 6063+<a name="6"></a><h6><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 6">edit</a>]</span> <span class="mw-headline">6</span></h6>
 6064+<a name="3"></a><h3><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 3">edit</a>]</span> <span class="mw-headline">3</span></h3>
 6065+<a name="1_7"></a><h1><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 1">edit</a>]</span> <span class="mw-headline">1</span></h1>
 6066+<a name="5"></a><h5><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: 5">edit</a>]</span> <span class="mw-headline">5</span></h5>
 6067+<a name="2_4"></a><h2><span class="editsection">[<a href="https://www.mediawiki.org/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: 2">edit</a>]</span> <span class="mw-headline">2</span></h2>
 6068+
 6069+!! end
 6070+
 6071+
 6072+!! test
 6073+ISBN with a dummy number
 6074+!! input
 6075+ISBN ---
 6076+!! result
 6077+<p><a href="https://www.mediawiki.org/index.php?title=Special:Booksources&amp;isbn=" class="internal">ISBN ---</a>
 6078+</p>
 6079+!! end
 6080+
 6081+
 6082+!! test
 6083+Pages in namespace (Magic word disabled currently)
 6084+!! input
 6085+{{PAGESINNAMESPACE:}}
 6086+!! result
 6087+
 6088+!! end
 6089+
 6090+
58766091 #
58776092 #
58786093 #

Follow-up revisions

RevisionCommit summaryAuthorDate
r50157Cleanup in MagicWord::$mVariableIDs, removed IDs that aren't handled in Parse...ialex12:38, 3 May 2009
r65906Fixed a couple of typos....platonides16:32, 4 May 2010