r69220 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69219‎ | r69220 | r69221 >
Date:21:11, 9 July 2010
Author:maxsem
Status:ok
Tags:
Comment:
Follow-up to r67044: moved string function tests to a separate file protected by conditional, tweaked test runner to skip instead of exploding when required function hook is not found.
Modified paths:
  • /trunk/extensions/ParserFunctions/ParserFunctions.php (modified) (history)
  • /trunk/extensions/ParserFunctions/funcsParserTests.txt (modified) (history)
  • /trunk/extensions/ParserFunctions/stringFunctionTests.txt (added) (history)
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
@@ -1049,9 +1049,10 @@
10501050 /**
10511051 * Steal a callback function from the primary parser, save it for
10521052 * application to our scary parser. If the hook is not installed,
1053 - * die a painful dead to warn the others.
 1053+ * abort processing of this file.
10541054 *
10551055 * @param $name String
 1056+ * @return Bool true if tag hook is present
10561057 */
10571058 public function requireHook( $name ) {
10581059 global $wgParser;
@@ -1059,16 +1060,19 @@
10601061 if ( isset( $wgParser->mTagHooks[$name] ) ) {
10611062 $this->hooks[$name] = $wgParser->mTagHooks[$name];
10621063 } else {
1063 - wfDie( "This test suite requires the '$name' hook extension.\n" );
 1064+ echo " This test suite requires the '$name' hook extension, skipping.\n";
 1065+ return false;
10641066 }
 1067+ return true;
10651068 }
10661069
10671070 /**
10681071 * Steal a callback function from the primary parser, save it for
10691072 * application to our scary parser. If the hook is not installed,
1070 - * die a painful dead to warn the others.
 1073+ * abort processing of this file.
10711074 *
10721075 * @param $name String
 1076+ * @return Bool true if function hook is present
10731077 */
10741078 public function requireFunctionHook( $name ) {
10751079 global $wgParser;
@@ -1076,8 +1080,10 @@
10771081 if ( isset( $wgParser->mFunctionHooks[$name] ) ) {
10781082 $this->functionHooks[$name] = $wgParser->mFunctionHooks[$name];
10791083 } else {
1080 - wfDie( "This test suite requires the '$name' function hook extension.\n" );
 1084+ echo " This test suite requires the '$name' function hook extension, skipping.\n";
 1085+ return false;
10811086 }
 1087+ return true;
10821088 }
10831089
10841090 /*
@@ -1657,7 +1663,9 @@
16581664 foreach ( explode( "\n", $data['hooks'] ) as $line ) {
16591665 $line = trim( $line );
16601666 if ( $line ) {
1661 - if ( $this->parser ) $this->parser->requireHook( $line );
 1667+ if ( $this->parser && !$this->parser->requireHook( $line ) ) {
 1668+ return false;
 1669+ }
16621670 }
16631671 }
16641672 $data = array();
@@ -1671,7 +1679,9 @@
16721680 foreach ( explode( "\n", $data['functionhooks'] ) as $line ) {
16731681 $line = trim( $line );
16741682 if ( $line ) {
1675 - if ( $this->parser ) $this->parser->requireFunctionHook( $line );
 1683+ if ( $this->parser && !$this->parser->requireFunctionHook( $line ) ) {
 1684+ return false;
 1685+ }
16761686 }
16771687 }
16781688 $data = array();
Index: trunk/extensions/ParserFunctions/ParserFunctions.php
@@ -46,6 +46,7 @@
4747 $wgExtensionMessagesFiles['ParserFunctionsMagic'] = dirname(__FILE__) . '/ParserFunctions.i18n.magic.php';
4848
4949 $wgParserTestFiles[] = dirname( __FILE__ ) . "/funcsParserTests.txt";
 50+$wgParserTestFiles[] = dirname( __FILE__ ) . "/stringFunctionTests.txt";
5051
5152 function wfSetupParserFunctions() {
5253 global $wgPFHookStub, $wgHooks;
Index: trunk/extensions/ParserFunctions/funcsParserTests.txt
@@ -175,17 +175,3 @@
176176 <p>false
177177 </p>
178178 !! end
179 -
180 -!! test
181 -#urldecode
182 -!! input
183 -{{#urldecode:}}
184 -{{#urldecode:foo%20bar}}
185 -{{#urldecode:%D0%9C%D0%B5%D0%B4%D0%B8%D0%B0%D0%92%D0%B8%D0%BA%D0%B8}}
186 -{{#urldecode: some unescaped string}}
187 -!! result
188 -<p>foo bar
189 -МедиаВики
190 -some unescaped string
191 -</p>
192 -!! end
Index: trunk/extensions/ParserFunctions/stringFunctionTests.txt
@@ -0,0 +1,32 @@
 2+# @todo expand
 3+!! functionhooks
 4+len
 5+!! endfunctionhooks
 6+
 7+!! test
 8+#len
 9+!! input
 10+{{#len:}}
 11+{{#len:0}}
 12+{{#len:test}}
 13+!!result
 14+<p>0
 15+1
 16+4
 17+</p>
 18+!! end
 19+
 20+!! test
 21+#urldecode
 22+!! input
 23+{{#urldecode:}}
 24+{{#urldecode:foo%20bar}}
 25+{{#urldecode:%D0%9C%D0%B5%D0%B4%D0%B8%D0%B0%D0%92%D0%B8%D0%BA%D0%B8}}
 26+{{#urldecode: some unescaped string}}
 27+!! result
 28+<p>foo bar
 29+МедиаВики
 30+some unescaped string
 31+</p>
 32+!! end
 33+
Property changes on: trunk/extensions/ParserFunctions/stringFunctionTests.txt
___________________________________________________________________
Added: svn:eol-style
134 + native

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r67044(bug 19940) urldecode dropped during StringFunctions-ParserFunctions mergermaxsem16:12, 29 May 2010

Status & tagging log