Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3373
pt-pf.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 21 2014, 9:28 PM
2014-11-21 21:28:09 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
pt-pf.patch
View Options
Index: maintenance/parserTests.inc
===================================================================
--- maintenance/parserTests.inc (revision 16513)
+++ maintenance/parserTests.inc (working copy)
@@ -93,6 +93,7 @@
}
$this->hooks = array();
+ $this->functionHooks = array();
}
/**
@@ -161,6 +162,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" );
@@ -258,6 +273,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 );
@@ -717,6 +735,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
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2941
Default Alt Text
pt-pf.patch (1 KB)
Attached To
Mode
T9801: add regression test support for parser functions
Attached
Detach File
Event Timeline
Log In to Comment