Index: trunk/phase3/maintenance/parserTests.inc |
— | — | @@ -370,7 +370,7 @@ |
371 | 371 | 'wgLanguageCode' => $lang, |
372 | 372 | 'wgContLanguageCode' => $lang, |
373 | 373 | 'wgDBprefix' => 'parsertest_', |
374 | | - |
| 374 | + 'wgRawHtml' => preg_match('/\\brawhtml\\b/i', $opts), |
375 | 375 | 'wgLang' => null, |
376 | 376 | 'wgContLang' => null, |
377 | 377 | 'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)), |
— | — | @@ -843,6 +843,7 @@ |
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
| 847 | +/* A colour-less terminal */ |
847 | 848 | class DummyTermColorer { |
848 | 849 | function color( $color ) { |
849 | 850 | return ''; |
— | — | @@ -894,9 +895,9 @@ |
895 | 896 | } |
896 | 897 | |
897 | 898 | 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 |
901 | 902 | |
902 | 903 | function __construct( $term ) { |
903 | 904 | parent::__construct( $term ); |
— | — | @@ -962,11 +963,15 @@ |
963 | 964 | array( 'previously FAILING test(s) removed O_o', 0, null ), |
964 | 965 | array( 'new FAILING test(s) :(', null, 0 ), |
965 | 966 | ); |
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); |
970 | 972 | printf( "%4d %s\n", $count, $label ); |
| 973 | + foreach ($differences as $differing_test_name) { |
| 974 | + print " * $differing_test_name\n"; |
| 975 | + } |
971 | 976 | } |
972 | 977 | } |
973 | 978 | } else { |
— | — | @@ -976,19 +981,20 @@ |
977 | 982 | } |
978 | 983 | |
979 | 984 | /** |
980 | | - * :P |
| 985 | + ** @desc: Returns an array of the test names with changed results, based on the specified |
| 986 | + ** before/after criteria. |
981 | 987 | */ |
982 | | - private function comparisonCount( $before, $after ) { |
| 988 | + private function compareResult( $before, $after ) { |
983 | 989 | $testitem = $this->db->tableName( 'testitem' ); |
984 | 990 | $prevRun = intval( $this->prevRun ); |
985 | 991 | $curRun = intval( $this->curRun ); |
986 | 992 | $prevStatus = $this->condition( $before ); |
987 | 993 | $curStatus = $this->condition( $after ); |
988 | 994 | |
989 | | - // note: requires a current mysql for subselects |
| 995 | + // note: requires mysql >= ver 4.1 for subselects |
990 | 996 | if( is_null( $after ) ) { |
991 | 997 | $sql = " |
992 | | - select count(*) as c from $testitem as prev |
| 998 | + select prev.ti_name as t from $testitem as prev |
993 | 999 | where prev.ti_run=$prevRun and |
994 | 1000 | prev.ti_success $prevStatus and |
995 | 1001 | (select current.ti_success from $testitem as current |
— | — | @@ -996,7 +1002,7 @@ |
997 | 1003 | and prev.ti_name=current.ti_name) $curStatus"; |
998 | 1004 | } else { |
999 | 1005 | $sql = " |
1000 | | - select count(*) as c from $testitem as current |
| 1006 | + select current.ti_name as t from $testitem as current |
1001 | 1007 | where current.ti_run=$curRun and |
1002 | 1008 | current.ti_success $curStatus and |
1003 | 1009 | (select prev.ti_success from $testitem as prev |
— | — | @@ -1004,11 +1010,17 @@ |
1005 | 1011 | and prev.ti_name=current.ti_name) $prevStatus"; |
1006 | 1012 | } |
1007 | 1013 | $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 | + } |
1009 | 1018 | $this->db->freeResult( $result ); |
1010 | | - return $row->c; |
| 1019 | + return $retval; |
1011 | 1020 | } |
1012 | 1021 | |
| 1022 | + /** |
| 1023 | + ** @desc: Helper function for compareResult() database querying. |
| 1024 | + */ |
1013 | 1025 | private function condition( $value ) { |
1014 | 1026 | if( is_null( $value ) ) { |
1015 | 1027 | return 'IS NULL'; |
Index: trunk/phase3/maintenance/parserTests.txt |
— | — | @@ -5871,7 +5871,222 @@ |
5872 | 5872 | |
5873 | 5873 | !!end |
5874 | 5874 | |
| 5875 | +!! test |
| 5876 | +[Before] HTML without raw HTML enabled ($wgRawHtml==false) |
| 5877 | +!! input |
| 5878 | +<html><script>alert(1);</script></html> |
| 5879 | +!! result |
| 5880 | +<p><html><script>alert(1);</script></html> |
| 5881 | +</p> |
| 5882 | +!! end |
5875 | 5883 | |
| 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&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&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&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&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/..&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////&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&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 </dt><dd> def |
| 5966 | +</dd><dt> title </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>[[: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&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>><> |
| 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&action=edit&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&action=edit&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&action=edit&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&action=edit&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&action=edit&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&action=edit&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&action=edit&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&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 | + |
5876 | 6091 | # |
5877 | 6092 | # |
5878 | 6093 | # |