From 600d985ad5cb01c83007e149c72137a5c099e073 Mon Sep 17 00:00:00 2001 From: Nick Jenkins Date: Wed, 15 Nov 2006 04:06:00 +0000 Subject: [PATCH] * 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). --- maintenance/parserTests.inc | 42 ++++--- maintenance/parserTests.txt | 215 ++++++++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+), 15 deletions(-) diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index b2552032f5..f3b1754f54 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -370,7 +370,7 @@ class ParserTest { 'wgLanguageCode' => $lang, 'wgContLanguageCode' => $lang, 'wgDBprefix' => 'parsertest_', - + 'wgRawHtml' => preg_match('/\\brawhtml\\b/i', $opts), 'wgLang' => null, 'wgContLang' => null, 'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)), @@ -843,6 +843,7 @@ class AnsiTermColorer { } } +/* A colour-less terminal */ class DummyTermColorer { function color( $color ) { return ''; @@ -894,9 +895,9 @@ class TestRecorder { } class DbTestRecorder extends TestRecorder { - var $db; ///< Database connection to the main DB - var $curRun; ///< run ID number for the current run - var $prevRun; ///< run ID number for the previous run, if any + private $db; ///< Database connection to the main DB + private $curRun; ///< run ID number for the current run + private $prevRun; ///< run ID number for the previous run, if any function __construct( $term ) { parent::__construct( $term ); @@ -962,11 +963,15 @@ class DbTestRecorder extends TestRecorder { array( 'previously FAILING test(s) removed O_o', 0, null ), array( 'new FAILING test(s) :(', null, 0 ), ); - foreach( $table as $blah ) { - list( $label, $before, $after ) = $blah; - $count = $this->comparisonCount( $before, $after ); - if( $count ) { + foreach( $table as $criteria ) { + list( $label, $before, $after ) = $criteria; + $differences = $this->compareResult( $before, $after ); + if( $differences ) { + $count = count($differences); printf( "%4d %s\n", $count, $label ); + foreach ($differences as $differing_test_name) { + print " * $differing_test_name\n"; + } } } } else { @@ -976,19 +981,20 @@ class DbTestRecorder extends TestRecorder { } /** - * :P + ** @desc: Returns an array of the test names with changed results, based on the specified + ** before/after criteria. */ - private function comparisonCount( $before, $after ) { + private function compareResult( $before, $after ) { $testitem = $this->db->tableName( 'testitem' ); $prevRun = intval( $this->prevRun ); $curRun = intval( $this->curRun ); $prevStatus = $this->condition( $before ); $curStatus = $this->condition( $after ); - // note: requires a current mysql for subselects + // note: requires mysql >= ver 4.1 for subselects if( is_null( $after ) ) { $sql = " - select count(*) as c from $testitem as prev + select prev.ti_name as t from $testitem as prev where prev.ti_run=$prevRun and prev.ti_success $prevStatus and (select current.ti_success from $testitem as current @@ -996,7 +1002,7 @@ class DbTestRecorder extends TestRecorder { and prev.ti_name=current.ti_name) $curStatus"; } else { $sql = " - select count(*) as c from $testitem as current + select current.ti_name as t from $testitem as current where current.ti_run=$curRun and current.ti_success $curStatus and (select prev.ti_success from $testitem as prev @@ -1004,11 +1010,17 @@ class DbTestRecorder extends TestRecorder { and prev.ti_name=current.ti_name) $prevStatus"; } $result = $this->db->query( $sql, __METHOD__ ); - $row = $this->db->fetchObject( $result ); + $retval = array(); + while ($row = $this->db->fetchObject( $result )) { + $retval[] = $row->t; + } $this->db->freeResult( $result ); - return $row->c; + return $retval; } + /** + ** @desc: Helper function for compareResult() database querying. + */ private function condition( $value ) { if( is_null( $value ) ) { return 'IS NULL'; diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 4eab18b19d..ff48509a3a 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -5871,6 +5871,221 @@ TODO: Images with the "|" character in the comment !!end +!! test +[Before] HTML without raw HTML enabled ($wgRawHtml==false) +!! input + +!! result +

<html><script>alert(1);</script></html> +

+!! end + +!! test +HTML with raw HTML ($wgRawHtml==true) +!! options +rawhtml +!! input + +!! result +

+

+!! end + +!! test +Parents of subpages, one level up +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! input +[[../|L2]] +!! result +

L2 +

+!! end + + +!! test +Parents of subpages, one level up, not named +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! input +[[../]] +!! result +

Subpage test/L1/L2 +

+!! end + + + +!! test +Parents of subpages, two levels up +!! options +disabled +subpage title=[[Subpage test/L1/L2/L3]] +!! input +[[../../|L1]]2 +!! result +

L1 +

+!! end + + +# Question: should result be "/index.php?title=Subpage_test/L1&action=edit" instead? +!! test +TODO: Parents of subpages, two levels up, without trailing slash or name. +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! input +[[../..]] +!! result +

../.. +

+!! end + +# Question: Why should the link text in the above test be "../..", yet in this test the "../.." part is silently dropped? +# Current result:

/// +!! test +TODO: Parents of subpages, two levels up, with lots of extra trailing slashes. +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! input +[[../../////]] +!! result +

Subpage test/L1 +

+!! end + +!! test +Definition list code coverage +!! input +; title : def +; title : def +;title: def +!! result +
title  
def +
title 
def +
title
def +
+ +!! end + +!! test +TODO: Don't fall for the self-closing div +!! input +
hello world
+!! result +
hello world
+ +!! end + +!! test +MSGNW magic word +!! input +{{MSGNW:msg}} +!! result +

[[:Template:Msg]] +

+!! end + +!! test +RAW magic word +!! input +{{RAW:QUERTY}} +!! result +

Template:QUERTY +

+!! end + +!! test +TODO: Always escape literal '>' in output, not just after '<' +!! input +><> +!! result +

><> +

+!! end + +!! test +Template caching +!! input +{{Test}} +{{Test}} +!! result +

This is a test template +This is a test template +

+!! end + + +!! article +MediaWiki:Fake +!! text +==header== +!! endarticle + +!! test +Inclusion of !userCanEdit() content +!! input +{{MediaWiki:Fake}} +!! result +

[edit] header

+ +!! end + + +!! test +Out-of-order TOC heading levels +!! input +==2== +======6====== +===3=== +=1= +=====5===== +==2== +!! result +

Contents

+ +
+

[edit] 2

+
[edit] 6
+

[edit] 3

+

[edit] 1

+
[edit] 5
+

[edit] 2

+ +!! end + + +!! test +ISBN with a dummy number +!! input +ISBN --- +!! result +

ISBN --- +

+!! end + + +!! test +Pages in namespace (Magic word disabled currently) +!! input +{{PAGESINNAMESPACE:}} +!! result + +!! end + # # -- 2.20.1