For MediaWiki (recent comments | status changes | tags | authors | states | release notes)
Index: trunk/phase3/maintenance/parserTests.inc =================================================================== --- trunk/phase3/maintenance/parserTests.inc (revision 17409) +++ trunk/phase3/maintenance/parserTests.inc (revision 17410) @@ -99,6 +99,7 @@ } $this->hooks = array(); + $this->functionHooks = array(); } /** @@ -167,6 +168,20 @@ $section = null; continue; } + if( $section == 'endfunctionhooks' ) { + if( !isset( $data['functionhooks'] ) ) { + wfDie( "'endfunctionhooks' without 'functionhooks' at line $n\n" ); + } + foreach( explode( "\n", $data['functionhooks'] ) as $line ) { + $line = trim( $line ); + if( $line ) { + $this->requireFunctionHook( $line ); + } + } + $data = array(); + $section = null; + continue; + } if( $section == 'end' ) { if( !isset( $data['test'] ) ) { wfDie( "'end' without 'test' at line $n\n" ); @@ -264,6 +279,9 @@ foreach( $this->hooks as $tag => $callback ) { $parser->setHook( $tag, $callback ); } + foreach( $this->functionHooks as $tag => $callback ) { + $parser->setFunctionHook( $tag, $callback ); + } wfRunHooks( 'ParserTestParser', array( &$parser ) ); $title =& Title::makeTitle( NS_MAIN, $titleText ); @@ -729,6 +747,22 @@ } } + + /** + * Steal a callback function from the primary parser, save it for + * application to our scary parser. If the hook is not installed, + * die a painful dead to warn the others. + * @param string $name + */ + private function requireFunctionHook( $name ) { + global $wgParser; + if( isset( $wgParser->mFunctionHooks[$name] ) ) { + $this->functionHooks[$name] = $wgParser->mFunctionHooks[$name]; + } else { + wfDie( "This test suite requires the '$name' function hook extension.\n" ); + } + } + /* * Run the "tidy" command on text if the $wgUseTidy * global is true Index: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES (revision 17409) +++ trunk/phase3/RELEASE-NOTES (revision 17410) @@ -140,6 +140,7 @@ * (bug 7774) MATH: aded more amstex functions * (bug 1182) MATH: fixed inconsistent rendering of upper case Greek letters in TeX * Fix regression in streaming page dump generation +* (bug 7801) Add support for parser function hooks in parser tests == Languages updated ==