From b32e5630715aa8116d3cf79b624e97abeee2f97d Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 18 Oct 2006 09:22:33 +0000 Subject: [PATCH] Added --show-output option to parserTests.php, to allow capture of complete output for test generation. Fixed various parser tests broken by tidy and incorrect capture method (i.e. web browser). Updated "Fuzz testing: Parser14-table", this appears to be fixed. --- maintenance/parserTests.inc | 13 ++++- maintenance/parserTests.php | 22 ++++---- maintenance/parserTests.txt | 106 ++++++++++++++---------------------- 3 files changed, 65 insertions(+), 76 deletions(-) diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index 0aabd27b42..1ccd0aaaa3 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -25,7 +25,7 @@ */ /** */ -$options = array( 'quick', 'color', 'quiet', 'help' ); +$options = array( 'quick', 'color', 'quiet', 'help', 'show-output' ); $optionsWithArgs = array( 'regex' ); require_once( 'commandLine.inc' ); @@ -53,6 +53,11 @@ class ParserTest { */ var $lightcolor; + /** + * boolean $showOutput Show test output + */ + var $showOutput; + /** * Sets terminal colorization and diff/quick modes depending on OS and * command-line options (--color and --quick). @@ -82,8 +87,9 @@ class ParserTest { } $this->showDiffs = !isset( $options['quick'] ); - $this->quiet = isset( $options['quiet'] ); + $this->showOutput = isset( $options['show-output'] ); + if (isset($options['regex'])) { $this->regex = $options['regex']; @@ -586,6 +592,9 @@ class ParserTest { $this->showTesting( $desc ); } print $this->termColor( '1;31' ) . 'FAILED!' . $this->termReset() . "\n"; + if ( $this->showOutput ) { + print "--- Expected ---\n$result\n--- Actual ---\n$html\n"; + } if( $this->showDiffs ) { print $this->quickDiff( $result, $html ); if( !$this->wellFormed( $html ) ) { diff --git a/maintenance/parserTests.php b/maintenance/parserTests.php index 309bf2e07c..f38c1d7b8b 100644 --- a/maintenance/parserTests.php +++ b/maintenance/parserTests.php @@ -26,22 +26,24 @@ require('parserTests.inc'); if( isset( $options['help'] ) ) { - echo <<] [--file=] [--help] Options: - --quick Suppress diff output of failed tests - --quiet Suppress notification of passed tests (shows only failed tests) - --color Override terminal detection and force color output on or off - 'light' option is similar to 'yes' but with color for dark backgrounds - --regex Only run tests whose descriptions which match given regex - --file Run test cases from a custom file instead of parserTests.txt - --help Show this help message + --quick Suppress diff output of failed tests + --quiet Suppress notification of passed tests (shows only failed tests) + --show-output Show expected and actual output + --color Override terminal detection and force color output on or off + 'light' option is similar to 'yes' but with color for dark backgrounds + --regex Only run tests whose descriptions which match given regex + --file Run test cases from a custom file instead of parserTests.txt + --help Show this help message -END; +ENDS; exit( 0 ); } diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 04af385e8d..8026c83602 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3136,8 +3136,6 @@ es:Alimento fr:Nourriture zh:食品 ### !! test Basic section headings -!! options -title=[[Parser test script]] !! input == Headline 1 == Some text @@ -3147,23 +3145,19 @@ More ===Smaller headline=== Blah blah !! result -

[edit] Headline 1

- +

[edit] Headline 1

Some text

-

[edit] Headline 2

+

[edit] Headline 2

More

-

[edit] Smaller headline

+

[edit] Smaller headline

Blah blah -

!! end !! test Section headings with TOC -!! options -title=[[Parser test script]] !! input == Headline 1 == === Subheadline 1 === @@ -3174,8 +3168,7 @@ title=[[Parser test script]] Some text ===Another headline=== !! result -

Contents

[hide]
- +

Contents

- -
-

[edit] Headline 1

-

[edit] Subheadline 1

- -
[edit] Skipping a level
-
[edit] Skipping a level
-

[edit] Headline 2

- +
+

[edit] Headline 1

+

[edit] Subheadline 1

+
[edit] Skipping a level
+
[edit] Skipping a level
+

[edit] Headline 2

Some text

-

[edit] Another headline

+

[edit] Another headline

+ !! end # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10' @@ -3226,8 +3216,7 @@ Handling of sections up to level 6 and beyond ========= Level 9 Heading========= ========== Level 10 Heading========== !! result -

Contents

[hide]
- +

Contents

-

[edit] Level 1 Heading

-

[edit] Level 2 Heading

+
+

[edit] Level 1 Heading

+

[edit] Level 2 Heading

+

[edit] Level 3 Heading

+

[edit] Level 4 Heading

+
[edit] Level 5 Heading
+
[edit] Level 6 Heading
+
[edit] = Level 7 Heading=
+
[edit] == Level 8 Heading==
+
[edit] === Level 9 Heading===
+
[edit] ==== Level 10 Heading====
-

[edit] Level 3 Heading

-

[edit] Level 4 Heading

-
[edit] Level 5 Heading
- -
[edit] Level 6 Heading
-
[edit] = Level 7 Heading=
-
[edit] == Level 8 Heading==
- -
[edit] === Level 9 Heading===
-
[edit] ==== Level 10 Heading====
!! end !! test Resolving duplicate section names -!! options -title=[[Parser test script]] !! input == Foo bar == == Foo bar == !! result -

[edit] Foo bar

+

[edit] Foo bar

+

[edit] Foo bar

-

[edit] Foo bar

!! end !! article @@ -3296,19 +3278,16 @@ Template:sections !! test Template with sections, __NOTOC__ -!! options -title=[[Parser test script]] !! input __NOTOC__ ==Section 0== {{sections}} ==Section 4== !! result -

[edit] Section 0

- -

[edit] Section 1

-

[edit] Section 2

-

[edit] Section 4

+

[edit] Section 0

+

[edit] Section 1

+

[edit] Section 2

+

[edit] Section 4

!! end @@ -3320,18 +3299,17 @@ __NOEDITSECTION__ ==Section 2== !! result

Section 1

-

Section 2

+ !! end !! test Link inside a section heading -!! options -title=[[Parser test script]] !! input ==Section with a [[Main Page|link]] in it== !! result -

[edit] Section with a link in it

+

[edit] Section with a link in it

+ !! end @@ -4471,13 +4449,12 @@ Fuzz testing: Parser14 == onmouseover= == http://__TOC__ !! result -

[edit] onmouseover=

-http://

Contents

[hide]
+

[edit] onmouseover=

+http://

Contents

-
+
!! end @@ -4487,10 +4464,11 @@ Fuzz testing: Parser14-table ==a== {| STYLE=__TOC__ !! result -

[edit] a

- - -
+

[edit] a

+ + +
+ !! end # Known to produce bogus xml (extra ) @@ -5873,4 +5851,4 @@ more tables math character entities and much more -Try for 100% code coverage \ No newline at end of file +Try for 100% code coverage -- 2.20.1